ezBun
Make running Bun sandboxes easy. ezbun is a CLI tool that scans your project for scripts and provides an interactive menu to run them. It also includes built-in environment variable validation and type generation.
% bun dev_Features
Interactive Menu
Select scripts to run via a CLI interface.
Env Validation
Validates environment variables using Zod before running scripts.
Type Safety
Automatically generates env.d.ts for type-safe process.env.
Watch Mode
Supports running scripts in watch mode.
Installation
Note: zod is a peer dependency and must be installed separately.
Usage
Without direct installation with bunx:
Installed into your project:
Tip. you can add a script to your package.json:
Then run:
CLI Options
Customize behavior with command-line flags:
Available options:
--dir, -d- Source directory (default: ./src)--extensions, -e- Comma-separated extensions (default: ts,tsx,js,jsx,cjs,mjs)--watch- Run in watch mode
Watch Mode
You can run scripts in watch mode (hot reloading) by passing the --watch flag:
Environment Variables
ezbun makes handling environment variables easy and type-safe.
1. Create an env.schema.ts file in your project root:
2. When you run a script via ezbun, it will:
- Validate
process.envagainst your schema. - Print helpful error messages if validation fails.
- Automatically generate
env.d.tsfor global type definitions.
Now you can use process.env with full type safety in your code!