fix: v2.5.1 — plugin npm runs no longer depend on PATH (Windows update failure)
A Windows self-update failed at "bootstrap": 'npm.cmd' is not recognized. The update chain runs with the dashboard server's environment, whose PATH need not reach npm.cmd, and the bootstrap looked npm up through cmd.exe (shell: true, which also printed DEP0190). - npmCommand() in scripts/plugin-bootstrap.js runs the npm bundled with the running node (npm-cli.js beside process.execPath, Windows and Unix layouts) with no shell, and puts that node's directory first on PATH (kept under the env's own Path/PATH key) so npm scripts find the same node; npm on PATH only when that node ships none - Used by the runtime install, the UI build (plugin-open.js) and the doctor's npm row (plugin-doctor.js)
This commit is contained in:
@@ -29,10 +29,12 @@ const boot = require("./plugin-bootstrap");
|
||||
const { resolveDashboardPort } = require("../server/lib/server-info");
|
||||
|
||||
const PLUGIN_ROOT = path.resolve(__dirname, "..");
|
||||
const NPM = process.platform === "win32" ? "npm.cmd" : "npm";
|
||||
const NPM = "npm";
|
||||
|
||||
function run(cmd, args, cwd, stdio) {
|
||||
const res = spawnSync(cmd, args, { cwd, stdio, shell: process.platform === "win32" });
|
||||
/** `cmd` is always NPM: run through `boot.npmCommand`, never a PATH lookup. */
|
||||
function run(_cmd, args, cwd, stdio) {
|
||||
const npm = boot.npmCommand(args);
|
||||
const res = spawnSync(npm.file, npm.args, { cwd, stdio, env: npm.env, shell: npm.shell });
|
||||
return res.status === 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user