Skip to content

Commit 3e3ed18

Browse files
thecjharriesblakeembrey
authored andcommitted
Use TypeScript project option (TypeStrong#588)
1 parent f06735d commit 3e3ed18

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib/utils/options/readers/tsconfig.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,27 @@ export class TSConfigReader extends OptionsComponent {
2323
*/
2424
private static OPTIONS_KEY = 'tsconfig';
2525

26+
/**
27+
* The name of the parameter that specifies the TS project
28+
*
29+
* https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L49
30+
*/
31+
private static PROJECT_KEY = 'project';
32+
2633
initialize() {
2734
this.listenTo(this.owner, DiscoverEvent.DISCOVER, this.onDiscover, -100);
2835
}
2936

3037
onDiscover(event: DiscoverEvent) {
3138
if (TSConfigReader.OPTIONS_KEY in event.data) {
3239
this.load(event, Path.resolve(event.data[TSConfigReader.OPTIONS_KEY]));
40+
} else if (TSConfigReader.PROJECT_KEY in event.data) {
41+
// The `project` option may be a directory or file, so use TS to find it
42+
let file: string = ts.findConfigFile(event.data[TSConfigReader.PROJECT_KEY], ts.sys.fileExists);
43+
// If file is undefined, we found no file to load.
44+
if (file) {
45+
this.load(event, file);
46+
}
3347
} else if (this.application.isCLI) {
3448
let file: string = ts.findConfigFile('.', ts.sys.fileExists);
3549
// If file is undefined, we found no file to load.

0 commit comments

Comments
 (0)