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

Function buildNpmScriptCommand

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

Source from the content-addressed store, hash-verified

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