Skip to content

Commit 60c12f9

Browse files
committed
_findConfigPathForFolder() now also stops if it reaches a folder containing package.json
1 parent 7494cde commit 60c12f9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tsdoc-config/src/TSDocConfigFile.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,22 @@ export class TSDocConfigFile {
251251
if (folderPath) {
252252
let foundFolder: string = folderPath;
253253
for (;;) {
254-
const tsconfigFilePath: string = path.join(foundFolder, 'tsconfig.json');
255-
if (fs.existsSync(tsconfigFilePath)) {
256-
// Success
254+
const tsconfigJsonPath: string = path.join(foundFolder, 'tsconfig.json');
255+
if (fs.existsSync(tsconfigJsonPath)) {
256+
// Stop when we reach a folder containing tsconfig.json
257+
return path.join(foundFolder, TSDocConfigFile.FILENAME);
258+
}
259+
const packageJsonPath: string = path.join(foundFolder, 'package.json');
260+
if (fs.existsSync(packageJsonPath)) {
261+
// Stop when we reach a folder containing package.json; this avoids crawling out of the current package
257262
return path.join(foundFolder, TSDocConfigFile.FILENAME);
258263
}
259264

260265
const previousFolder: string = foundFolder;
261266
foundFolder = path.dirname(foundFolder);
262267

263268
if (!foundFolder || foundFolder === previousFolder) {
264-
// Failed
269+
// Give up if we reach the filesystem root directory
265270
break;
266271
}
267272
}

0 commit comments

Comments
 (0)