Fix windows build

This commit is contained in:
Sander Declerck 2025-12-03 11:42:22 +01:00
parent 0fd54b159b
commit a578ee7213
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
import { build } from "esbuild"; import { build } from "esbuild";
import { mkdir, cp, rm, readFile, writeFile } from "node:fs/promises"; import { mkdir, cp, rm, readFile, writeFile } from "node:fs/promises";
import { spawn } from "node:child_process"; import { spawn } from "node:child_process";
import { resolve } from "node:path";
const target = process.argv[2]; const target = process.argv[2];
if (!target) { if (!target) {
@ -102,8 +103,13 @@ async function copyAndModifyPackageJson() {
} }
function buildSafeChainBinary(target) { function buildSafeChainBinary(target) {
return new Promise((resolve, reject) => { return new Promise((promiseResolve, reject) => {
const pkg = spawn("./node_modules/.bin/pkg", ["./build/package.json", "-t", target], { // Use .cmd on Windows, resolve to absolute path for cross-platform compatibility
const pkgBin = process.platform === "win32"
? resolve("node_modules/.bin/pkg.cmd")
: resolve("node_modules/.bin/pkg");
const pkg = spawn(pkgBin, ["./build/package.json", "-t", target], {
stdio: "inherit", stdio: "inherit",
shell: true, shell: true,
}); });
@ -112,7 +118,7 @@ function buildSafeChainBinary(target) {
if (code !== 0) { if (code !== 0) {
reject(new Error(`pkg process exited with code ${code}`)); reject(new Error(`pkg process exited with code ${code}`));
} else { } else {
resolve(); promiseResolve();
} }
}); });
}); });