Skip to content

Commit fa1d273

Browse files
author
Alan Agius
committed
fix: use fs sync method to write files
In certain cases the stats are not written, this seems to be because the process is being terminated before it finish to write. The reason being is using a sync version of tap. To get around this, the sync method of fs should be used to allow the creation of files. Related to: angular/angular-cli#12763
1 parent cffa93f commit fa1d273

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,12 @@ module.exports = class SpeedMeasurePlugin {
140140
chalk.enabled = true;
141141
if (outputToFile) {
142142
const writeMethod = fs.existsSync(this.options.outputTarget)
143-
? fs.appendFile
144-
: fs.writeFile;
145-
writeMethod(this.options.outputTarget, output + "\n", err => {
146-
if (err) throw err;
147-
console.log(
148-
smpTag() + "Outputted timing info to " + this.options.outputTarget
149-
);
150-
});
143+
? fs.appendFileSync
144+
: fs.writeFileSync;
145+
writeMethod(this.options.outputTarget, output + "\n");
146+
console.log(
147+
smpTag() + "Outputted timing info to " + this.options.outputTarget
148+
);
151149
} else {
152150
const outputFunc = this.options.outputTarget || console.log;
153151
outputFunc(output);

0 commit comments

Comments
 (0)