aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSoccera1 <[email protected]>2026-06-15 21:10:43 +1000
committerSoccera1 <[email protected]>2026-07-13 17:02:02 +1000
commit7ea75fb4424af8df393dd75dfb9b14a08aa46959 (patch)
tree52772fa63c7ae0581b44d0c0b164252934acf5f0 /bin
downloadbnu-7ea75fb4424af8df393dd75dfb9b14a08aa46959.tar.gz
bnu-7ea75fb4424af8df393dd75dfb9b14a08aa46959.zip
Initial commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bnu.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/bnu.js b/bin/bnu.js
new file mode 100755
index 0000000..b451084
--- /dev/null
+++ b/bin/bnu.js
@@ -0,0 +1,22 @@
+#!/usr/bin/env bun
+import { realpathSync } from "node:fs";
+import { basename, dirname, join } from "node:path";
+import { pathToFileURL } from "node:url";
+
+const here = dirname(realpathSync(Bun.argv[1]));
+globalThis[Symbol.for("bnu.cli")] = true;
+const { commandNames, main } = await import(pathToFileURL(join(here, "../src/coreutils.js")).href);
+let invokedPath = Bun.argv[1];
+try {
+ if (process.env._ && realpathSync(process.env._) === realpathSync(Bun.argv[1])) invokedPath = process.env._;
+} catch {
+ // Fall back to Bun's resolved script path when the shell-provided path is not usable.
+}
+const invokedAs = basename(invokedPath).replace(/\.js$/, "");
+const argv = invokedAs === "bnu"
+ ? Bun.argv.slice(2)
+ : commandNames.includes(invokedAs)
+ ? [invokedAs, ...Bun.argv.slice(2)]
+ : ["coreutils", `--coreutils-prog=${invokedAs}`, ...Bun.argv.slice(2)];
+
+process.exit(await main(argv));