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

Function buildNpmScriptCommand

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

Source from the content-addressed store, hash-verified

842export { buildRuntimeServicesInfo };
843
844export 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
877export function validateLocalAgentServerPath(localPath) {
878 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