File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -251,17 +251,22 @@ export class TSDocConfigFile {
251
251
if ( folderPath ) {
252
252
let foundFolder : string = folderPath ;
253
253
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
257
262
return path . join ( foundFolder , TSDocConfigFile . FILENAME ) ;
258
263
}
259
264
260
265
const previousFolder : string = foundFolder ;
261
266
foundFolder = path . dirname ( foundFolder ) ;
262
267
263
268
if ( ! foundFolder || foundFolder === previousFolder ) {
264
- // Failed
269
+ // Give up if we reach the filesystem root directory
265
270
break ;
266
271
}
267
272
}
You can’t perform that action at this time.
0 commit comments