Don't leave behind an unused package.json.tmp file

This commit is contained in:
SteveSandersonMS
2016-12-13 17:19:38 +00:00
parent a76b6e25d4
commit 4580412f73

View File

@@ -137,6 +137,7 @@ class MyGenerator extends yeoman.Base {
if (emitFile) { if (emitFile) {
let inputFullPath = path.join(templateRoot, fn); let inputFullPath = path.join(templateRoot, fn);
let destinationFullPath = this.destinationPath(outputFn); let destinationFullPath = this.destinationPath(outputFn);
let deleteInputFileAfter = false;
if (path.basename(fn) === 'package.json') { if (path.basename(fn) === 'package.json') {
// Special handling for package.json, because we rewrite it dynamically // Special handling for package.json, because we rewrite it dynamically
const tempPath = destinationFullPath + '.tmp'; const tempPath = destinationFullPath + '.tmp';
@@ -147,6 +148,7 @@ class MyGenerator extends yeoman.Base {
/* space */ 2 /* space */ 2
); );
inputFullPath = tempPath; inputFullPath = tempPath;
deleteInputFileAfter = true;
} }
const outputDirBasename = path.basename(path.dirname(destinationFullPath)); const outputDirBasename = path.basename(path.dirname(destinationFullPath));
@@ -164,6 +166,10 @@ class MyGenerator extends yeoman.Base {
this._answers this._answers
); );
} }
if (deleteInputFileAfter) {
this.fs.delete(inputFullPath);
}
} }
}); });
} }