From d906d608038db549e871961dc8f5c75a47f54b1f Mon Sep 17 00:00:00 2001 From: JLarky Date: Wed, 20 Sep 2023 22:22:47 -0600 Subject: [PATCH] how to add package bin; make is-bun executable --- _build_npm.ts | 9 ++++++++- cli.ts | 3 +++ mod.ts | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cli.ts diff --git a/_build_npm.ts b/_build_npm.ts index 3f9b74f..48563eb 100755 --- a/_build_npm.ts +++ b/_build_npm.ts @@ -13,7 +13,14 @@ async function start() { await emptyDir("./npm"); await build({ - entryPoints: ["./mod.ts"], + entryPoints: [ + "./mod.ts", + { + kind: "bin", + name: "is-bun", + path: "./cli.ts", + }, + ], outDir: "./npm", shims: {}, test: false, diff --git a/cli.ts b/cli.ts new file mode 100644 index 0000000..ac214ab --- /dev/null +++ b/cli.ts @@ -0,0 +1,3 @@ +import { printIsBun } from "./mod.ts"; + +printIsBun(); diff --git a/mod.ts b/mod.ts index addf7ef..c8d4b0f 100644 --- a/mod.ts +++ b/mod.ts @@ -3,3 +3,11 @@ export function isBun(): boolean { // @ts-ignore return typeof Bun !== "undefined"; } + +export function printIsBun() { + if (isBun()) { + console.log("Buntime runtime!"); + } else { + console.log("It's not Bun, hun."); + } +}