Skip to content

Commit f5908b9

Browse files
committed
only rewrite if rewriting is required
1 parent 03c9c95 commit f5908b9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/stub-generator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,18 @@ StubGenerator.prototype.build = function() {
7676

7777
var content = fs.readFileSync(fullInputPath, 'UTF8');
7878
var imports = importsFor(content, fullInputPath);
79+
var needsImportsReWritten = false;
7980

8081
Object.keys(imports).forEach(function(name) {
82+
needsImportsReWritten = true;
8183
imports[name].version = versionForModuleName(name, this.basedir);
8284
}, this);
8385

84-
// TODO: only add files that required rewriting
85-
fs.writeFileSync(fullOutputPath, rewriteImports(content, imports));
86+
if (needsImportsReWritten) {
87+
fs.writeFileSync(fullOutputPath, rewriteImports(content, imports));
88+
} else {
89+
fs.writeFileSync(fullOutputPath, content);
90+
}
8691

8792
this.stubs.set(fullInputPath, imports);
8893

0 commit comments

Comments
 (0)