Skip to content

Commit 15d7fef

Browse files
committed
fix(build): use shell on Windows for pnpm/npm/npx in build script
1 parent 5812984 commit 15d7fef

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

scripts/build-desktop-artifact.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from "node:fs";
2424
import { createRequire } from "node:module";
2525
import { tmpdir } from "node:os";
26-
import { dirname, join, resolve } from "node:path";
26+
import { basename, dirname, join, resolve } from "node:path";
2727
import { fileURLToPath } from "node:url";
2828

2929
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
@@ -75,12 +75,23 @@ function parseArgs(argv) {
7575

7676
function run(command, commandArgs, options = {}) {
7777
const printable = [command, ...commandArgs].join(" ");
78+
const shellCommands = new Set(["pnpm", "npm", "npx"]);
79+
const commandLower = command.toLowerCase();
80+
const usesShellOnWindows =
81+
process.platform === "win32" &&
82+
(shellCommands.has(basename(command)) ||
83+
commandLower.endsWith(".cmd") ||
84+
commandLower.endsWith(".bat"));
7885
console.log(`\n[stage] $ ${printable}${options.cwd ? ` (cwd=${options.cwd})` : ""}`);
7986
const result = spawnSync(command, commandArgs, {
8087
stdio: "inherit",
8188
env: process.env,
89+
shell: usesShellOnWindows,
8290
...options,
8391
});
92+
if (result.error) {
93+
throw new Error(`Command failed to start (${result.error.message}): ${printable}`);
94+
}
8495
if (result.status !== 0) {
8596
throw new Error(`Command failed (${result.status ?? "signal"}): ${printable}`);
8697
}

0 commit comments

Comments
 (0)