Skip to content

Commit

Permalink
feat: Add Node.js as script runner
Browse files Browse the repository at this point in the history
  • Loading branch information
xymopen committed Dec 26, 2024
1 parent cd1d2c0 commit 8ca89b0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extensions/npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The extension fetches data from <https://registry.npmjs.org> and <https://regist
- `npm.autoDetect` - Enable detecting scripts as tasks, the default is `on`.
- `npm.runSilent` - Run npm script with the `--silent` option, the default is `false`.
- `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.
- `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.
- `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.
- `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;'.
- `npm.enableScriptExplorer` - Enable an explorer view for npm scripts.
- `npm.scriptExplorerAction` - The default click action: `open` or `run`, the default is `open`.
Expand Down
28 changes: 15 additions & 13 deletions extensions/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,16 @@
"npm",
"yarn",
"pnpm",
"bun"
"bun",
"node"
],
"enumDescriptions": [
"%config.npm.scriptRunner.auto%",
"%config.npm.scriptRunner.npm%",
"%config.npm.scriptRunner.yarn%",
"%config.npm.scriptRunner.pnpm%",
"%config.npm.scriptRunner.bun%"
"%config.npm.scriptRunner.bun%",
"%config.npm.scriptRunner.node%"
],
"default": "auto",
"description": "%config.npm.scriptRunner%"
Expand Down Expand Up @@ -361,18 +363,18 @@
}
],
"terminalQuickFixes": [
{
"id": "ms-vscode.npm-command",
"commandLineMatcher": "npm",
"commandExitResult": "error",
"outputMatcher": {
"anchor": "bottom",
"length": 8,
"lineMatcher": "Did you mean (?:this|one of these)\\?((?:\\n.+?npm .+ #.+)+)",
"offset": 2
}
{
"id": "ms-vscode.npm-command",
"commandLineMatcher": "npm",
"commandExitResult": "error",
"outputMatcher": {
"anchor": "bottom",
"length": 8,
"lineMatcher": "Did you mean (?:this|one of these)\\?((?:\\n.+?npm .+ #.+)+)",
"offset": 2
}
]
}
]
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions extensions/npm/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"config.npm.scriptRunner.yarn": "Use yarn as the script runner.",
"config.npm.scriptRunner.pnpm": "Use pnpm as the script runner.",
"config.npm.scriptRunner.bun": "Use bun as the script runner.",
"config.npm.scriptRunner.node": "Use Node.js as the script runner.",
"config.npm.scriptRunner.auto": "Auto-detect which script runner to use based on lock files and installed package managers.",
"config.npm.exclude": "Configure glob patterns for folders that should be excluded from automatic script detection.",
"config.npm.enableScriptExplorer": "Enable an explorer view for npm scripts when there is no top-level 'package.json' file.",
Expand Down
4 changes: 2 additions & 2 deletions extensions/npm/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export async function createScriptRunnerTask(context: ExtensionContext, script:
}
const taskName = getTaskName(script, relativePackageJson);
const cwd = path.dirname(packageJsonUri.fsPath);
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(scriptRunner, getCommandLine(folder.uri, ['run', script]), { cwd: cwd }));
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(scriptRunner, getCommandLine(folder.uri, [scriptRunner === 'node' ? '--run' : 'run', script]), { cwd: cwd }));
task.detail = scriptValue;

const lowerCaseTaskName = script.toLowerCase();
Expand Down Expand Up @@ -438,7 +438,7 @@ export async function startDebugging(context: ExtensionContext, scriptName: stri

commands.executeCommand(
'extension.js-debug.createDebuggerTerminal',
`${scriptRunner} run ${scriptName}`,
`${scriptRunner} ${scriptRunner === 'node' ? '--run' : 'run'} ${scriptName}`,
folder,
{ cwd },
);
Expand Down

0 comments on commit 8ca89b0

Please sign in to comment.