Skip to content

Commit cc2e35f

Browse files
committed
Fixed preprocessor setup. No correctly detects missing tsconfig.json and skips.
1 parent f1b3f5a commit cc2e35f

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

index.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
/* eslint-env node */
22

3+
const fs = require('fs');
4+
const path = require('path');
35
const SilentError = require('silent-error');
6+
const TsPreprocessor = require('./lib/typescript-preprocessor');
47

5-
let TsPreprocessor;
6-
try {
7-
TsPreprocessor = require('./lib/typescript-preprocessor');
8-
} catch (ex) {
9-
// Do nothing; we just won't have the plugin available. This means that if you
10-
// somehow end up in a state where it doesn't load, the preprocessor *will*
11-
// fail, but this is necessary because the preprocessor depends on packages
12-
// which aren't installed until the
13-
}
148

159
module.exports = {
1610
name: 'ember-cli-typescript',
1711

1812
setupPreprocessorRegistry(type, registry) {
19-
if (!TsPreprocessor) {
20-
this.ui.write(
21-
'Note: TypeScript preprocessor not available -- some dependencies not installed. ' +
22-
'(If this is during installation of the add-on, this is as expected. If it is ' +
23-
'while building, serving, or testing the application, this is an error.)'
13+
if (!fs.existsSync(path.join(this.project.root, 'tsconfig.json'))) {
14+
// Do nothing; we just won't have the plugin available. This means that if you
15+
// somehow end up in a state where it doesn't load, the preprocessor *will*
16+
// fail, but this is necessary because the preprocessor depends on packages
17+
// which aren't installed until the default blueprint is run
18+
19+
this.ui.writeInfoLine(
20+
'Skipping TypeScript preprocessing as there is no tsconfig.json. ' +
21+
'(If this is during installation of the add-on, this is as expected. If it is ' +
22+
'while building, serving, or testing the application, this is an error.)'
2423
);
2524
return;
2625
}
@@ -30,7 +29,7 @@ module.exports = {
3029
ui: this.ui
3130
}));
3231
} catch (ex) {
33-
throw new SilentError(`Missing or invalid tsconfig.json, please fix or run \`ember generate ember-cli-typescript\`.\n${ex}`);
32+
throw new SilentError(`Failed to instantiate TypeScript preprocessor, probably due to an invalid tsconfig.json. Please fix or run \`ember generate ember-cli-typescript\`.\n${ex}`);
3433
}
3534
},
3635
};

0 commit comments

Comments
 (0)