Fixing #76711 handle the case that a script is customized in the tasks.json

This commit is contained in:
Erich Gamma 2019-08-27 19:40:34 +02:00
parent 4bf092c438
commit 9fee53765e

View file

@ -145,25 +145,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
subscriptions.push(commands.registerCommand('npm.runInstall', this.runInstall, this));
}
private scriptIsValid(scripts: any, task: Task): boolean {
for (const script in scripts) {
let label = getTaskName(script, task.definition.path);
if (task.name === label) {
return true;
}
}
return false;
}
private async runScript(script: NpmScript) {
let task = script.task;
let uri = getPackageJsonUriFromTask(task);
let scripts = await getScripts(uri!);
if (!this.scriptIsValid(scripts, task)) {
this.scriptNotValid(task);
return;
}
tasks.executeTask(script.task);
}
@ -176,11 +158,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
let uri = getPackageJsonUriFromTask(task);
let scripts = await getScripts(uri!);
if (!this.scriptIsValid(scripts, task)) {
this.scriptNotValid(task);
return;
}
let debugArg = this.extractDebugArg(scripts, task);
if (!debugArg) {
let message = localize('noDebugOptions', 'Could not launch "{0}" for debugging because the scripts lacks a node debug option, e.g. "--inspect-brk".', task.name);
@ -195,11 +172,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
startDebugging(task.name, debugArg[0], debugArg[1], script.getFolder());
}
private scriptNotValid(task: Task) {
let message = localize('scriptInvalid', 'Could not find the script "{0}". Try to refresh the view.', task.name);
window.showErrorMessage(message);
}
private findScript(document: TextDocument, script?: NpmScript): number {
let scriptOffset = 0;
let inScripts = false;