( scriptName, platform = process.platform, env = process.env, nodeExecPath = process.execPath, )
| 786 | export { buildRuntimeServicesInfo }; |
| 787 | |
| 788 | export function buildNpmScriptCommand( |
| 789 | scriptName, |
| 790 | platform = process.platform, |
| 791 | env = process.env, |
| 792 | nodeExecPath = process.execPath, |
| 793 | ) { |
| 794 | // On Windows, always use cmd.exe regardless of whether npm_execpath is set. |
| 795 | // npm_execpath points to a path like |
| 796 | // "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" which contains |
| 797 | // spaces. When that path is passed as an argument with shell:true in |
| 798 | // spawnService, cmd.exe splits on the space and tries to run "C:\Program" |
| 799 | // as a command, producing "not recognized as an internal or external command". |
| 800 | // Using "npm" via cmd.exe avoids the problem entirely. |
| 801 | if (platform === "win32") { |
| 802 | return { |
| 803 | command: env.ComSpec || "cmd.exe", |
| 804 | args: ["/d", "/s", "/c", "npm", "run", scriptName], |
| 805 | }; |
| 806 | } |
| 807 | |
| 808 | if (env.npm_execpath) { |
| 809 | return { |
| 810 | command: env.npm_node_execpath || nodeExecPath, |
| 811 | args: [env.npm_execpath, "run", scriptName], |
| 812 | }; |
| 813 | } |
| 814 | |
| 815 | return { |
| 816 | command: "npm", |
| 817 | args: ["run", scriptName], |
| 818 | }; |
| 819 | } |
| 820 | |
| 821 | export function validateLocalAgentServerPath(localPath) { |
| 822 | if (!path.isAbsolute(localPath)) { |
no outgoing calls
no test coverage detected