Skip to content

Commit 54edcdc

Browse files
committed
Move incremental output to OS temp
1 parent da18bba commit 54edcdc

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

blueprints/ember-cli-typescript/index.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@ module.exports = {
3838
},
3939

4040
afterInstall() {
41-
if (existsSync('.gitignore')) {
42-
this.insertIntoFile('.gitignore', '\n# Ember CLI TypeScript\n.e-c-ts');
43-
}
44-
45-
if (existsSync('.vscode/settings.json')) {
46-
// NOTE: this may or may not actually work -- it assumes that
47-
// `"tmp:": true` is in fact set.
48-
this.insertIntoFile('.vscode/settings.json', '",\n.e-c-ts": true', {
49-
after: '"tmp": true',
50-
});
51-
}
52-
53-
// TODO: same for Atom
54-
// TODO: same for Sublime
55-
// TODO: same for IntelliJ
56-
5741
return this.addPackagesToProject([
5842
{ name: 'typescript', target: 'latest' },
5943
{ name: '@types/ember', target: 'latest' },

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-env node */
33

44
const fs = require('fs');
5+
const os = require('os');
56
const path = require('path');
67
const SilentError = require('silent-error');
78
const TsPreprocessor = require('./lib/typescript-preprocessor');
@@ -17,6 +18,16 @@ module.exports = {
1718
return this.project._isRunningServeTS;
1819
},
1920

21+
_tempDir() {
22+
if (!this.project._tsTempDir) {
23+
const tempDir = path.join(os.tmpdir(), `e-c-ts-${process.pid}`);
24+
this.project._tsTempDir = tempDir;
25+
mkdirp.sync(tempDir);
26+
}
27+
28+
return this.project._tsTempDir;
29+
},
30+
2031
_inRepoAddons() {
2132
const pkg = this.project.pkg;
2233
if (!pkg || !pkg['ember-addon'] || !pkg['ember-addon'].paths) {
@@ -28,7 +39,7 @@ module.exports = {
2839

2940
includedCommands() {
3041
return {
31-
'serve-ts': buildServeCommand(this.project),
42+
'serve-ts': buildServeCommand(this.project, this._tempDir()),
3243
};
3344
},
3445

@@ -75,10 +86,10 @@ module.exports = {
7586

7687
// funnel will fail if the directory doesn't exist
7788
roots.forEach(root => {
78-
mkdirp.sync(path.join('.e-c-ts', root));
89+
mkdirp.sync(path.join(this._tempDir(), root));
7990
});
8091

81-
const ts = funnel('.e-c-ts', {
92+
const ts = funnel(this._tempDir(), {
8293
exclude: ['tests'],
8394
getDestinationPath(relativePath) {
8495
const prefix = roots.find(root => relativePath.startsWith(root));
@@ -99,7 +110,7 @@ module.exports = {
99110
return tree;
100111
}
101112

102-
const tests = path.join('.e-c-ts', 'tests');
113+
const tests = path.join(this._tempDir(), 'tests');
103114

104115
// funnel will fail if the directory doesn't exist
105116
mkdirp.sync(tests);

lib/serve-ts.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ const child_process = require('child_process');
55
const fs = require('fs');
66

77
const rimraf = require('rimraf');
8-
const OUT_DIR = '.e-c-ts';
98

10-
module.exports = (project) => {
9+
module.exports = (project, outDir) => {
1110
const Serve = project.require('ember-cli/lib/commands/serve');
1211
const Builder = project.require('ember-cli/lib/models/builder');
1312
const Watcher = project.require('ember-cli/lib/models/watcher');
@@ -71,7 +70,7 @@ module.exports = (project) => {
7170
'node_modules/typescript/bin/tsc',
7271
[
7372
'--watch',
74-
'--outDir', OUT_DIR,
73+
'--outDir', outDir,
7574
'--allowJs', 'false',
7675
'--noEmit', 'false',
7776
'--sourceMap', 'false', // TODO: enable if sourcemaps=true
@@ -97,8 +96,8 @@ module.exports = (project) => {
9796
this.tsc.kill();
9897
}
9998

100-
if (fs.existsSync(OUT_DIR)) {
101-
rimraf.sync(OUT_DIR);
99+
if (fs.existsSync(outDir)) {
100+
rimraf.sync(outDir);
102101
}
103102
});
104103
},

0 commit comments

Comments
 (0)