Skip to content

Commit

Permalink
how to add package bin; make is-bun executable
Browse files Browse the repository at this point in the history
  • Loading branch information
JLarky committed Sep 21, 2023
1 parent 74cbe6b commit d906d60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion _build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { printIsBun } from "./mod.ts";

printIsBun();
8 changes: 8 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

0 comments on commit d906d60

Please sign in to comment.