Skip to content

Commit 7aed7f4

Browse files
this the script?
1 parent 59bd643 commit 7aed7f4

File tree

1 file changed

+46
-0
lines changed
  • packages/@pglt/pglt/bin

1 file changed

+46
-0
lines changed

packages/@pglt/pglt/bin/pglt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env node
2+
const { platform, arch, env } = process;
3+
4+
/**
5+
* platform and arch are values injected into the node runtime.
6+
* We use the values documented on https://nodejs.org.
7+
*/
8+
const PLATFORMS = {
9+
win32: {
10+
x64: "@pglt/cli-x86_64-windows-msvc/pglt.exe",
11+
arm64: "@pglt/cli-aarch64-windows-msvc/pglt.exe",
12+
},
13+
darwin: {
14+
x64: "@pglt/cli-x86_64-apple-darwin/pglt",
15+
arm64: "@pglt/cli-aarch64-apple-darwin/pglt",
16+
},
17+
linux: {
18+
x64: "@pglt/cli-x86_64-linux-gnu/pglt",
19+
arm64: "@pglt/cli-aarch64-linux-gnu/pglt",
20+
},
21+
};
22+
23+
const binPath = env.PGLT_BINARY || PLATFORMS?.[platform]?.[arch];
24+
25+
if (binPath) {
26+
const result = require("child_process").spawnSync(
27+
require.resolve(binPath),
28+
process.argv.slice(2),
29+
{
30+
shell: false,
31+
stdio: "inherit",
32+
env,
33+
}
34+
);
35+
36+
if (result.error) {
37+
throw result.error;
38+
}
39+
40+
process.exitCode = result.status;
41+
} else {
42+
console.error(
43+
"The pglt CLI package doesn't ship with prebuilt binaries for your platform yet. Please file an issue in the main repository."
44+
);
45+
process.exitCode = 1;
46+
}

0 commit comments

Comments
 (0)