Skip to content

Commit 2a9988b

Browse files
committed
Also look for api-extractor.json in the "./config" folder
1 parent 522f9c7 commit 2a9988b

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

apps/api-extractor/src/cli/RunAction.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,22 @@ export class RunAction extends CommandLineAction {
115115
// at the project root
116116
const packageFolder: string | undefined = lookup.tryGetPackageFolderFor('.');
117117

118-
if (packageFolder) {
119-
configFilename = path.join(packageFolder, AE_CONFIG_FILENAME);
118+
// If there is no package, then try the current directory
119+
const baseFolder: string = packageFolder ? packageFolder : process.cwd();
120+
121+
// First try the standard "config" subfolder:
122+
configFilename = path.join(baseFolder, 'config', AE_CONFIG_FILENAME);
123+
if (FileSystem.exists(configFilename)) {
124+
if (FileSystem.exists(path.join(baseFolder, AE_CONFIG_FILENAME))) {
125+
throw new Error(`Found conflicting ${AE_CONFIG_FILENAME} files in "." and "./config" folders`);
126+
}
120127
} else {
121-
// If there is no package, then try the current directory
122-
configFilename = path.join(process.cwd(), AE_CONFIG_FILENAME);
123-
}
128+
// Otherwise try the top-level folder
129+
configFilename = path.join(baseFolder, AE_CONFIG_FILENAME);
124130

125-
if (!FileSystem.exists(configFilename)) {
126-
throw new Error(`Unable to find an ${AE_CONFIG_FILENAME} file`);
131+
if (!FileSystem.exists(configFilename)) {
132+
throw new Error(`Unable to find an ${AE_CONFIG_FILENAME} file`);
133+
}
127134
}
128135

129136
console.log(`Using configuration from ${configFilename}` + os.EOL + os.EOL);

0 commit comments

Comments
 (0)