From d022a7b517fa58b03e2ac5c04fd2eb993806189a Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Sun, 17 Dec 2023 22:09:59 +0800 Subject: [PATCH 1/2] fix: `install` in `npm script` shouldn't be opened --- extensions/npm/src/npmView.ts | 5 +++-- extensions/npm/src/tasks.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/npm/src/npmView.ts b/extensions/npm/src/npmView.ts index d087e75347a..496ad88f0a2 100644 --- a/extensions/npm/src/npmView.ts +++ b/extensions/npm/src/npmView.ts @@ -16,7 +16,8 @@ import { createTask, getPackageManager, getTaskName, isAutoDetectionEnabled, isWorkspaceFolder, INpmTaskDefinition, NpmTaskProvider, startDebugging, - ITaskWithLocation + ITaskWithLocation, + INSTALL_SCRIPT } from './tasks'; @@ -82,7 +83,7 @@ class NpmScript extends TreeItem { : task.task.name; super(name, TreeItemCollapsibleState.None); this.taskLocation = task.location; - const command: ExplorerCommands = workspace.getConfiguration('npm').get('scriptExplorerAction') || 'open'; + const command: ExplorerCommands = name === INSTALL_SCRIPT ? 'run' : workspace.getConfiguration('npm').get('scriptExplorerAction') || 'open'; const commandList = { 'open': { diff --git a/extensions/npm/src/tasks.ts b/extensions/npm/src/tasks.ts index 17bb815f962..390da48cf58 100644 --- a/extensions/npm/src/tasks.ts +++ b/extensions/npm/src/tasks.ts @@ -31,7 +31,7 @@ type AutoDetect = 'on' | 'off'; let cachedTasks: ITaskWithLocation[] | undefined = undefined; -const INSTALL_SCRIPT = 'install'; +export const INSTALL_SCRIPT = 'install'; export interface ITaskLocation { document: Uri; From f78d488f80fe655de47ac3ec6cce88995b7c721f Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Tue, 19 Dec 2023 20:33:30 +0800 Subject: [PATCH 2/2] fix: task name end with space --- extensions/npm/src/npmView.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/npm/src/npmView.ts b/extensions/npm/src/npmView.ts index 496ad88f0a2..38768b47710 100644 --- a/extensions/npm/src/npmView.ts +++ b/extensions/npm/src/npmView.ts @@ -83,7 +83,7 @@ class NpmScript extends TreeItem { : task.task.name; super(name, TreeItemCollapsibleState.None); this.taskLocation = task.location; - const command: ExplorerCommands = name === INSTALL_SCRIPT ? 'run' : workspace.getConfiguration('npm').get('scriptExplorerAction') || 'open'; + const command: ExplorerCommands = name === `${INSTALL_SCRIPT} ` ? 'run' : workspace.getConfiguration('npm').get('scriptExplorerAction') || 'open'; const commandList = { 'open': {