-
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathmake.js
More file actions
34 lines (24 loc) · 1.17 KB
/
make.js
File metadata and controls
34 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { execSync } from "child_process";
import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
import { platform } from "os";
const run = (cmd) => execSync(cmd, { stdio: "inherit" });
const binPath = platform() === "win32" ? ".\\build\\float.exe" : "./build/float";
// Clean build directory
rmSync("./build", { recursive: true, force: true });
rmSync("./dist", { recursive: true, force: true });
// Bundle the code
run("npx esbuild ./src/float.ts --bundle --minify --tree-shaking=true --platform=node --outfile=./dist/float.cjs");
// Test bundle
run(`node ./dist/float.cjs --sanityCheck`);
// Copy node binary and version file
mkdirSync("./build", { recursive: true });
copyFileSync(process.execPath, binPath);
writeFileSync("./build/version", JSON.parse(readFileSync("./package.json")).version);
// Create the blob
run("node --experimental-sea-config ./sea-config.json");
// Inject the blob
run(`npx postject ${binPath} NODE_SEA_BLOB ./dist/float.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA`);
// Clean up version directory
run("rimraf ./build/version");
// Test binary
run(`${binPath} --sanityCheck`);