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

Function buildNpmScriptCommand

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

Source from the content-addressed store, hash-verified

731export { buildRuntimeServicesInfo };
732
733export function buildNpmScriptCommand(
734 scriptName,
735 platform = process.platform,
736 env = process.env,
737 nodeExecPath = process.execPath,
738) {
739 // On Windows, always use cmd.exe regardless of whether npm_execpath is set.
740 // npm_execpath points to a path like
741 // "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" which contains
742 // spaces. When that path is passed as an argument with shell:true in
743 // spawnService, cmd.exe splits on the space and tries to run "C:\Program"
744 // as a command, producing "not recognized as an internal or external command".
745 // Using "npm" via cmd.exe avoids the problem entirely.
746 if (platform === "win32") {
747 return {
748 command: env.ComSpec || "cmd.exe",
749 args: ["/d", "/s", "/c", "npm", "run", scriptName],
750 };
751 }
752
753 if (env.npm_execpath) {
754 return {
755 command: env.npm_node_execpath || nodeExecPath,
756 args: [env.npm_execpath, "run", scriptName],
757 };
758 }
759
760 return {
761 command: "npm",
762 args: ["run", scriptName],
763 };
764}
765
766export function validateLocalAgentServerPath(localPath) {
767 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