Fix npm.scripsExplorerExclude for multiroot

Fixes #138826
This commit is contained in:
Alex Ross 2021-12-15 11:58:15 +01:00
parent 1b2c610ffe
commit ae3b03a7eb
No known key found for this signature in database
GPG key ID: 89DDDBA66CBA7840

View file

@ -291,11 +291,17 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
let folder = null;
let packageJson = null;
const regularExpressionsSetting = workspace.getConfiguration('npm').get<string[]>('scriptExplorerExclude', []);
const regularExpressions = regularExpressionsSetting?.map(value => RegExp(value));
const excludeConfig: Map<string, RegExp[]> = new Map();
tasks.forEach(each => {
if (regularExpressions.some((regularExpression) => (<NpmTaskDefinition>each.task.definition).script.match(regularExpression))) {
const location = each.location;
if (location && !excludeConfig.has(location.uri.toString())) {
const regularExpressionsSetting = workspace.getConfiguration('npm', location.uri).get<string[]>('scriptExplorerExclude', []);
excludeConfig.set(location.uri.toString(), regularExpressionsSetting?.map(value => RegExp(value)));
}
const regularExpressions = (location && excludeConfig.has(location.uri.toString())) ? excludeConfig.get(location.uri.toString()) : undefined;
if (regularExpressions && regularExpressions.some((regularExpression) => (<NpmTaskDefinition>each.task.definition).script.match(regularExpression))) {
return;
}