( scriptName, platform = process.platform, env = process.env, nodeExecPath = process.execPath, )
| 842 | export { buildRuntimeServicesInfo }; |
| 843 | |
| 844 | export function buildNpmScriptCommand( |
| 845 | scriptName, |
| 846 | platform = process.platform, |
| 847 | env = process.env, |
| 848 | nodeExecPath = process.execPath, |
| 849 | ) { |
| 850 | // On Windows, always use cmd.exe regardless of whether npm_execpath is set. |
| 851 | // npm_execpath points to a path like |
| 852 | // "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" which contains |
| 853 | // spaces. When that path is passed as an argument with shell:true in |
| 854 | // spawnService, cmd.exe splits on the space and tries to run "C:\Program" |
| 855 | // as a command, producing "not recognized as an internal or external command". |
| 856 | // Using "npm" via cmd.exe avoids the problem entirely. |
| 857 | if (platform === "win32") { |
| 858 | return { |
| 859 | command: env.ComSpec || "cmd.exe", |
| 860 | args: ["/d", "/s", "/c", "npm", "run", scriptName], |
| 861 | }; |
| 862 | } |
| 863 | |
| 864 | if (env.npm_execpath) { |
| 865 | return { |
| 866 | command: env.npm_node_execpath || nodeExecPath, |
| 867 | args: [env.npm_execpath, "run", scriptName], |
| 868 | }; |
| 869 | } |
| 870 | |
| 871 | return { |
| 872 | command: "npm", |
| 873 | args: ["run", scriptName], |
| 874 | }; |
| 875 | } |
| 876 | |
| 877 | export function validateLocalAgentServerPath(localPath) { |
| 878 | if (!path.isAbsolute(localPath)) { |
no outgoing calls
no test coverage detected