Escape args before running spawn

This commit is contained in:
Sander Declerck 2025-09-24 14:29:49 +02:00
parent 534aeee457
commit 83141d375a
No known key found for this signature in database
3 changed files with 153 additions and 4 deletions

View file

@ -1,15 +1,18 @@
import { execSync } from "child_process";
import { ui } from "../../environment/userInteraction.js";
import { safeSpawnSync } from "../../utils/safeSpawn.js";
export function runPnpmCommand(args, toolName = "pnpm") {
try {
let result;
if (toolName === "pnpm") {
execSync(`pnpm ${args.join(" ")}`, { stdio: "inherit" });
result = safeSpawnSync("pnpm", args, { stdio: "inherit" });
} else if (toolName === "pnpx") {
execSync(`pnpx ${args.join(" ")}`, { stdio: "inherit" });
result = safeSpawnSync("pnpx", args, { stdio: "inherit" });
} else {
throw new Error(`Unsupported tool name for aikido-pnpm: ${toolName}`);
}
return { status: result.status };
} catch (error) {
if (error.status) {
return { status: error.status };
@ -18,5 +21,4 @@ export function runPnpmCommand(args, toolName = "pnpm") {
return { status: 1 };
}
}
return { status: 0 };
}