aboutsummaryrefslogtreecommitdiff
path: root/bin/npm.js
diff options
context:
space:
mode:
authorSoccera1 <[email protected]>2026-08-06 01:58:10 +1000
committerSoccera1 <[email protected]>2026-08-06 02:00:12 +1000
commitd11632d44b740ab8b78ec27544afb480f406a9d5 (patch)
tree7b56ee4e54a7858c01e1c8b4a74832e9db8eaa09 /bin/npm.js
parent471a0af4628e4796421fdba55ebc79bb4240c47e (diff)
downloadbnu-d11632d44b740ab8b78ec27544afb480f406a9d5.tar.gz
bnu-d11632d44b740ab8b78ec27544afb480f406a9d5.zip
Automatically publish to npm
Diffstat (limited to 'bin/npm.js')
-rw-r--r--bin/npm.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/npm.js b/bin/npm.js
new file mode 100644
index 0000000..4f45f0e
--- /dev/null
+++ b/bin/npm.js
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+import { spawn } from "node:child_process";
+import { createRequire } from "node:module";
+import { fileURLToPath } from "node:url";
+
+const require = createRequire(import.meta.url);
+const bun = require.resolve("bun/bin/bun.exe");
+const launcher = fileURLToPath(new URL("../runtime/bnu.js", import.meta.url));
+const child = spawn(bun, [launcher, ...process.argv.slice(2)], { stdio: "inherit" });
+
+child.on("error", (error) => {
+ console.error(`bnu: failed to start bundled Bun runtime: ${error.message}`);
+ process.exit(1);
+});
+
+child.on("exit", (code, signal) => {
+ if (signal) process.kill(process.pid, signal);
+ else process.exit(code ?? 1);
+});