Skip to content

Commit 60d4610

Browse files
committed
fix: clean up system temp directory when running.
While the system temp directory gets cleaned up semi-regularly, on long-running machines (e.g. CI servers), it is possible for the PID to get reused before the system temp directory gets cleared. When this happens, the temp directory we create as an intermediate location for TypeScript build artifacts (to prevent churn in the build) can end up being used for multiple builds, even across separate apps. This can result in very bad output from the build, including total runtime failures from things like `require` entries including files from different builds or apps. Prevent this by always running `fs.removeSync` on the temp output directory prior to setting it and putting new output there. Fixes #318.
1 parent 490cdb9 commit 60d4610

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/incremental-typescript-compiler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const symlinkOrCopy = require('symlink-or-copy');
88
const Plugin = require('broccoli-plugin');
99
const RSVP = require('rsvp');
1010
const path = require('path');
11-
const fs = require('fs');
11+
const fs = require('fs-extra');
1212
const resolve = require('resolve');
1313
const compile = require('./utilities/compile');
1414

@@ -88,6 +88,8 @@ module.exports = class IncrementalTypescriptCompiler {
8888
outDir() {
8989
if (!this._outDir) {
9090
let outDir = path.join(tmpdir(), `e-c-ts-${process.pid}`);
91+
fs.removeSync(outDir);
92+
9193
this._outDir = outDir;
9294
mkdirp.sync(outDir);
9395
}

0 commit comments

Comments
 (0)