Skip to content

Commit 93d53c6

Browse files
Gerrit0aciccarello
authored andcommitted
Don't limit option files to standard names (TypeStrong#944)
* Don't limit option files to standard names Fixes TypeStrong#942
1 parent 1b524ba commit 93d53c6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class TSConfigReader extends OptionsComponent {
4848
if (TSConfigReader.OPTIONS_KEY in event.data) {
4949
const tsconfig = event.data[TSConfigReader.OPTIONS_KEY];
5050

51-
if (/tsconfig\.json$/.test(tsconfig)) {
51+
if (FS.existsSync(tsconfig) && FS.statSync(tsconfig).isFile()) {
5252
file = Path.resolve(tsconfig);
5353
} else {
5454
file = ts.findConfigFile(tsconfig, ts.sys.fileExists);
@@ -59,8 +59,14 @@ export class TSConfigReader extends OptionsComponent {
5959
return;
6060
}
6161
} else if (TSConfigReader.PROJECT_KEY in event.data) {
62-
// The `project` option may be a directory or file, so use TS to find it
63-
file = ts.findConfigFile(event.data[TSConfigReader.PROJECT_KEY], ts.sys.fileExists);
62+
const resolved = Path.resolve(event.data[TSConfigReader.PROJECT_KEY]);
63+
// If the file exists, use it
64+
if (FS.existsSync(resolved)) {
65+
file = resolved;
66+
} else {
67+
// Use TS to find the file, since it could be a directory
68+
file = ts.findConfigFile(resolved, ts.sys.fileExists);
69+
}
6470
} else if (this.application.isCLI) {
6571
// No file or directory has been specified so find the file in the root of the project
6672
file = ts.findConfigFile('.', ts.sys.fileExists);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class TypedocReader extends OptionsComponent {
5050
return;
5151
}
5252
} else if (this.application.isCLI) {
53-
file = this.findTypedocFile();
53+
file = this.findTypedocFile(process.cwd());
5454
}
5555

5656
file && this.load(event, file);
@@ -63,8 +63,8 @@ export class TypedocReader extends OptionsComponent {
6363
* typedoc file will be attempted to be found at the root of this path
6464
* @return the typedoc.(js|json) file path or undefined
6565
*/
66-
findTypedocFile(path: string = process.cwd()): string | undefined {
67-
if (/typedoc\.js(on)?$/.test(path)) {
66+
findTypedocFile(path: string): string | undefined {
67+
if (FS.existsSync(path) && FS.statSync(path).isFile()) {
6868
return path;
6969
}
7070

0 commit comments

Comments
 (0)