@@ -12,10 +12,12 @@ import * as path from 'path';
1212import * as fs from 'fs' ;
1313import * as minimatch from 'minimatch' ;
1414import * as nls from 'vscode-nls' ;
15+ import { Utils } from 'vscode-uri' ;
1516import { findPreferredPM } from './preferred-pm' ;
1617import { readScripts } from './readScripts' ;
1718
1819const localize = nls . loadMessageBundle ( ) ;
20+ const excludeRegex = new RegExp ( '^(node_modules|.vscode-test)$' , 'i' ) ;
1921
2022export interface INpmTaskDefinition extends TaskDefinition {
2123 script : string ;
@@ -156,7 +158,7 @@ export async function hasNpmScripts(): Promise<boolean> {
156158 }
157159 try {
158160 for ( const folder of folders ) {
159- if ( isAutoDetectionEnabled ( folder ) ) {
161+ if ( isAutoDetectionEnabled ( folder ) && ! excludeRegex . test ( Utils . basename ( folder . uri ) ) ) {
160162 let relativePattern = new RelativePattern ( folder , '**/package.json' ) ;
161163 let paths = await workspace . findFiles ( relativePattern , '**/node_modules/**' ) ;
162164 if ( paths . length > 0 ) {
@@ -182,7 +184,7 @@ async function detectNpmScripts(context: ExtensionContext, showWarning: boolean)
182184 }
183185 try {
184186 for ( const folder of folders ) {
185- if ( isAutoDetectionEnabled ( folder ) ) {
187+ if ( isAutoDetectionEnabled ( folder ) && ! excludeRegex . test ( Utils . basename ( folder . uri ) ) ) {
186188 let relativePattern = new RelativePattern ( folder , '**/package.json' ) ;
187189 let paths = await workspace . findFiles ( relativePattern , '**/{node_modules,.vscode-test}/**' ) ;
188190 for ( const path of paths ) {
@@ -206,6 +208,9 @@ export async function detectNpmScriptsForFolder(context: ExtensionContext, folde
206208 let folderTasks : IFolderTaskItem [ ] = [ ] ;
207209
208210 try {
211+ if ( excludeRegex . test ( Utils . basename ( folder ) ) ) {
212+ return folderTasks ;
213+ }
209214 let relativePattern = new RelativePattern ( folder . fsPath , '**/package.json' ) ;
210215 let paths = await workspace . findFiles ( relativePattern , '**/node_modules/**' ) ;
211216
0 commit comments