Skip to content

Commit 3af34a5

Browse files
committed
feat: Add Node.js as script runner
1 parent 876f8d8 commit 3af34a5

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

extensions/npm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The extension fetches data from <https://registry.npmjs.org> and <https://regist
3535
- `npm.autoDetect` - Enable detecting scripts as tasks, the default is `on`.
3636
- `npm.runSilent` - Run npm script with the `--silent` option, the default is `false`.
3737
- `npm.packageManager` - The package manager used to install dependencies: `auto`, `npm`, `yarn`, `pnpm` or `bun`. The default is `auto`, which detects your package manager based on files in your workspace.
38-
- `npm.scriptRunner` - The script runner used to run the scripts: `auto`, `npm`, `yarn`, `pnpm` or `bun`. The default is `auto`, which detects your script runner based on files in your workspace.
38+
- `npm.scriptRunner` - The script runner used to run the scripts: `auto`, `npm`, `yarn`, `pnpm`, `bun` or `node`. The default is `auto`, which detects your script runner based on files in your workspace.
3939
- `npm.exclude` - Glob patterns for folders that should be excluded from automatic script detection. The pattern is matched against the **absolute path** of the package.json. For example, to exclude all test folders use '&ast;&ast;/test/&ast;&ast;'.
4040
- `npm.enableScriptExplorer` - Enable an explorer view for npm scripts.
4141
- `npm.scriptExplorerAction` - The default click action: `open` or `run`, the default is `open`.

extensions/npm/package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,16 @@
259259
"npm",
260260
"yarn",
261261
"pnpm",
262-
"bun"
262+
"bun",
263+
"node"
263264
],
264265
"enumDescriptions": [
265266
"%config.npm.scriptRunner.auto%",
266267
"%config.npm.scriptRunner.npm%",
267268
"%config.npm.scriptRunner.yarn%",
268269
"%config.npm.scriptRunner.pnpm%",
269-
"%config.npm.scriptRunner.bun%"
270+
"%config.npm.scriptRunner.bun%",
271+
"%config.npm.scriptRunner.node%"
270272
],
271273
"default": "auto",
272274
"description": "%config.npm.scriptRunner%"
@@ -361,18 +363,18 @@
361363
}
362364
],
363365
"terminalQuickFixes": [
364-
{
365-
"id": "ms-vscode.npm-command",
366-
"commandLineMatcher": "npm",
367-
"commandExitResult": "error",
368-
"outputMatcher": {
369-
"anchor": "bottom",
370-
"length": 8,
371-
"lineMatcher": "Did you mean (?:this|one of these)\\?((?:\\n.+?npm .+ #.+)+)",
372-
"offset": 2
373-
}
366+
{
367+
"id": "ms-vscode.npm-command",
368+
"commandLineMatcher": "npm",
369+
"commandExitResult": "error",
370+
"outputMatcher": {
371+
"anchor": "bottom",
372+
"length": 8,
373+
"lineMatcher": "Did you mean (?:this|one of these)\\?((?:\\n.+?npm .+ #.+)+)",
374+
"offset": 2
374375
}
375-
]
376+
}
377+
]
376378
},
377379
"repository": {
378380
"type": "git",

extensions/npm/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"config.npm.scriptRunner.yarn": "Use yarn as the script runner.",
1717
"config.npm.scriptRunner.pnpm": "Use pnpm as the script runner.",
1818
"config.npm.scriptRunner.bun": "Use bun as the script runner.",
19+
"config.npm.scriptRunner.node": "Use Node.js as the script runner.",
1920
"config.npm.scriptRunner.auto": "Auto-detect which script runner to use based on lock files and installed package managers.",
2021
"config.npm.exclude": "Configure glob patterns for folders that should be excluded from automatic script detection.",
2122
"config.npm.enableScriptExplorer": "Enable an explorer view for npm scripts when there is no top-level 'package.json' file.",

extensions/npm/src/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export async function createScriptRunnerTask(context: ExtensionContext, script:
342342
}
343343
const taskName = getTaskName(script, relativePackageJson);
344344
const cwd = path.dirname(packageJsonUri.fsPath);
345-
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(scriptRunner, getCommandLine(folder.uri, ['run', script]), { cwd: cwd }));
345+
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(scriptRunner, getCommandLine(folder.uri, [scriptRunner === 'node' ? '--run' : 'run', script]), { cwd: cwd }));
346346
task.detail = scriptValue;
347347

348348
const lowerCaseTaskName = script.toLowerCase();
@@ -439,7 +439,7 @@ export async function startDebugging(context: ExtensionContext, scriptName: stri
439439

440440
commands.executeCommand(
441441
'extension.js-debug.createDebuggerTerminal',
442-
`${scriptRunner} run ${scriptName}`,
442+
`${scriptRunner} ${scriptRunner === 'node' ? '--run' : 'run'} ${scriptName}`,
443443
folder,
444444
{ cwd },
445445
);

0 commit comments

Comments
 (0)