File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -358,7 +358,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
358358 private buildTaskTree ( tasks : Task [ ] ) : Folder [ ] | PackageJSON [ ] | NoScripts [ ] {
359359 let folders : Map < String , Folder > = new Map ( ) ;
360360 let packages : Map < String , PackageJSON > = new Map ( ) ;
361- let scripts : Map < String , NpmScript > = new Map ( ) ;
362361
363362 let folder = null ;
364363 let packageJson = null ;
@@ -380,11 +379,8 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
380379 packages . set ( fullPath , packageJson ) ;
381380 }
382381 let fullScriptPath = path . join ( packageJson . path , each . name ) ;
383- if ( ! scripts . get ( fullScriptPath ) ) {
384- let script = new NpmScript ( this . extensionContext , packageJson , each ) ;
385- packageJson . addScript ( script ) ;
386- scripts . set ( fullScriptPath , script ) ;
387- }
382+ let script = new NpmScript ( this . extensionContext , packageJson , each ) ;
383+ packageJson . addScript ( script ) ;
388384 }
389385 } ) ;
390386 if ( folders . size === 1 ) {
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ async function detectNpmScripts(): Promise<Task[]> {
100100
101101 let emptyTasks : Task [ ] = [ ] ;
102102 let allTasks : Task [ ] = [ ] ;
103+ let visitedPackageJsonFiles : Set < string > = new Set ( ) ;
103104
104105 let folders = workspace . workspaceFolders ;
105106 if ( ! folders ) {
@@ -112,8 +113,10 @@ async function detectNpmScripts(): Promise<Task[]> {
112113 let relativePattern = new RelativePattern ( folder , '**/package.json' ) ;
113114 let paths = await workspace . findFiles ( relativePattern , '**/node_modules/**' ) ;
114115 for ( let j = 0 ; j < paths . length ; j ++ ) {
115- if ( ! isExcluded ( folder , paths [ j ] ) ) {
116- let tasks = await provideNpmScriptsForFolder ( paths [ j ] ) ;
116+ let path = paths [ j ] ;
117+ if ( ! isExcluded ( folder , path ) && ! visitedPackageJsonFiles . has ( path . fsPath ) ) {
118+ let tasks = await provideNpmScriptsForFolder ( path ) ;
119+ visitedPackageJsonFiles . add ( path . fsPath ) ;
117120 allTasks . push ( ...tasks ) ;
118121 }
119122 }
You can’t perform that action at this time.
0 commit comments