mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix windows build
This commit is contained in:
parent
0fd54b159b
commit
a578ee7213
1 changed files with 9 additions and 3 deletions
12
build.js
12
build.js
|
|
@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue