MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / buildNpmScriptCommand

Function buildNpmScriptCommand

scripts/dev-safe.mjs:1085–1116  ·  view source on GitHub ↗
(
  scriptName,
  platform = process.platform,
  env = process.env,
  nodeExecPath = process.execPath,
)

Source from the content-addressed store, hash-verified

1083export { buildRuntimeServicesInfo };
1084
1085export 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
1118export function validateLocalAgentServerPath(localPath) {
1119 if (!path.isAbsolute(localPath)) {

Callers 4

startViteFunction · 0.90
buildFrontendFunction · 0.90
dev-safe.test.tsFile · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected