Bun Shell: type-safe cross-platform scripting
Posted by Sudhama Vipra · 2024-10-19
Bun Shell is production ready. Type-safe, cross-platform shell commands without bash. Replaces zx with better ergonomics and zero deps. https://github.com/oven-sh/bun
// Bun Shell — cross-platform scripting
import { $ } from 'bun';
const files = await $`ls -la src/`.text();
const count = await $`find . -name '*.ts' | wc -l`.text();
console.log(`TypeScript files: ${count.trim()}`);
try {
await $`docker build -t myapp .`;
await $`docker push myapp:latest`;
} catch (e) {
console.error(`Build failed: ${e.exitCode}`);
}