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

Function buildNpmScriptCommand

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

Source from the content-addressed store, hash-verified

786export { buildRuntimeServicesInfo };
787
788export function buildNpmScriptCommand(
789 scriptName,
790 platform = process.platform,
791 env = process.env,
792 nodeExecPath = process.execPath,
793) {
794 // On Windows, always use cmd.exe regardless of whether npm_execpath is set.
795 // npm_execpath points to a path like
796 // "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" which contains
797 // spaces. When that path is passed as an argument with shell:true in
798 // spawnService, cmd.exe splits on the space and tries to run "C:\Program"
799 // as a command, producing "not recognized as an internal or external command".
800 // Using "npm" via cmd.exe avoids the problem entirely.
801 if (platform === "win32") {
802 return {
803 command: env.ComSpec || "cmd.exe",
804 args: ["/d", "/s", "/c", "npm", "run", scriptName],
805 };
806 }
807
808 if (env.npm_execpath) {
809 return {
810 command: env.npm_node_execpath || nodeExecPath,
811 args: [env.npm_execpath, "run", scriptName],
812 };
813 }
814
815 return {
816 command: "npm",
817 args: ["run", scriptName],
818 };
819}
820
821export function validateLocalAgentServerPath(localPath) {
822 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