File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,13 @@ const leadingPathSegmentRegEx = /^(.?.[/\\])+/;
3030const moduleInfos = { } ;
3131const fileNodes = { } ;
3232
33- // Without explicit module ids, JSDoc will use the nearest shared ancestor directory
33+ // Without explicit module ids, JSDoc will use the nearest shared parent directory
3434/** @type {string } */
3535let implicitModuleRoot ;
3636
37+ /**
38+ * @return {string } The nearest shared parent directory of all source files.
39+ */
3740function getImplicitModuleRoot ( ) {
3841 if ( implicitModuleRoot ) {
3942 return implicitModuleRoot ;
@@ -43,19 +46,21 @@ function getImplicitModuleRoot() {
4346 return process . cwd ( ) ;
4447 }
4548
46- implicitModuleRoot = env . sourceFiles [ 0 ] ;
49+ implicitModuleRoot = path . dirname ( env . sourceFiles [ 0 ] ) ;
4750
4851 env . sourceFiles . slice ( 1 ) . forEach ( ( filePath ) => {
4952 if ( filePath . startsWith ( implicitModuleRoot ) ) {
50- return implicitModuleRoot ;
53+ return ;
5154 }
5255
5356 const currParts = filePath . split ( path . sep ) ;
5457 const nearestParts = implicitModuleRoot . split ( path . sep ) ;
5558
5659 for ( let i = 0 ; i < currParts . length ; ++ i ) {
5760 if ( currParts [ i ] !== nearestParts [ i ] ) {
58- return currParts . slice ( 0 , i ) . join ( path . sep ) ;
61+ implicitModuleRoot = currParts . slice ( 0 , i ) . join ( path . sep ) ;
62+
63+ return ;
5964 }
6065 }
6166 } ) ;
You can’t perform that action at this time.
0 commit comments