( scriptName, platform = process.platform, env = process.env, nodeExecPath = process.execPath, )
| 1083 | export { buildRuntimeServicesInfo }; |
| 1084 | |
| 1085 | export function buildNpmScriptCommand( |
| 1086 | scriptName, |
| 1087 | platform = process.platform, |
| 1088 | env = process.env, |
| 1089 | nodeExecPath = process.execPath, |
| 1090 | ) { |
| 1091 | // On Windows, always use cmd.exe regardless of whether npm_execpath is set. |
| 1092 | // npm_execpath points to a path like |
| 1093 | // "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" which contains |
| 1094 | // spaces. When that path is passed as an argument with shell:true in |
| 1095 | // spawnService, cmd.exe splits on the space and tries to run "C:\Program" |
| 1096 | // as a command, producing "not recognized as an internal or external command". |
| 1097 | // Using "npm" via cmd.exe avoids the problem entirely. |
| 1098 | if (platform === "win32") { |
| 1099 | return { |
| 1100 | command: env.ComSpec || "cmd.exe", |
| 1101 | args: ["/d", "/s", "/c", "npm", "run", scriptName], |
| 1102 | }; |
| 1103 | } |
| 1104 | |
| 1105 | if (env.npm_execpath) { |
| 1106 | return { |
| 1107 | command: env.npm_node_execpath || nodeExecPath, |
| 1108 | args: [env.npm_execpath, "run", scriptName], |
| 1109 | }; |
| 1110 | } |
| 1111 | |
| 1112 | return { |
| 1113 | command: "npm", |
| 1114 | args: ["run", scriptName], |
| 1115 | }; |
| 1116 | } |
| 1117 | |
| 1118 | export function validateLocalAgentServerPath(localPath) { |
| 1119 | if (!path.isAbsolute(localPath)) { |
no outgoing calls
no test coverage detected