A simple library to throw onto the top of your bun files to guard against that pesky node.js runtime or old versions of bun. Zero-dependency, utilizes Bun native Bun.semver
for comparisions.
$ bun install bun-check
import { bunCheck } from "bun-check";
// or
import bunCheck from "bun-check";
const opts = {
desiredVersion: ">=1.0.0",
error: ({message}) => {
console.log("go away node.js or old bun.");
process.exit();
},
}
bunCheck(opts);
type BunCheckOptions = {
desiredVersion?: string; // the desired version you want, see Bun.semver API [1]
error?: ({ message }: { message: string }) => void; // function either throws (default) or if provided an error callback, will fire that instead
}
[1] Bun Semver API