Use execSync instead of spawnSync for pnpm.

This commit is contained in:
Sander Declerck 2025-09-23 14:32:20 +02:00
parent e557887da9
commit 534aeee457
No known key found for this signature in database

View file

@ -1,33 +1,22 @@
import { spawnSync } from "child_process"; import { execSync } from "child_process";
import { ui } from "../../environment/userInteraction.js"; import { ui } from "../../environment/userInteraction.js";
export function runPnpmCommand(args, toolName = "pnpm") { export function runPnpmCommand(args, toolName = "pnpm") {
try { try {
let result;
ui.writeInformation(
`Executing ${toolName} with arguments:`,
args.join(" ")
);
ui.writeInformation("----------------------------");
if (toolName === "pnpm") { if (toolName === "pnpm") {
result = spawnSync("pnpm", args, { stdio: "inherit" }); execSync(`pnpm ${args.join(" ")}`, { stdio: "inherit" });
} else if (toolName === "pnpx") { } else if (toolName === "pnpx") {
result = spawnSync("pnpx", args, { stdio: "inherit" }); execSync(`pnpx ${args.join(" ")}`, { stdio: "inherit" });
} else { } else {
throw new Error(`Unsupported tool name for aikido-pnpm: ${toolName}`); throw new Error(`Unsupported tool name for aikido-pnpm: ${toolName}`);
} }
ui.writeInformation("----------------------------");
ui.writeInformation(`${toolName} process exited with code:`, result.status);
if (result.status !== null) {
return { status: result.status };
}
} catch (error) { } catch (error) {
if (error.status) {
return { status: error.status };
} else {
ui.writeError("Error executing command:", error.message); ui.writeError("Error executing command:", error.message);
return { status: 1 }; return { status: 1 };
} }
}
return { status: 0 }; return { status: 0 };
} }