Bun Shell
Bun의 $ 태그드 템플릿으로 셸 명령을 안전하게 실행합니다.
import { $ } from "bun";
// 기본 실행
await $`echo Hello, World!`;
// 변수 안전 주입 (자동 이스케이프)
const name = "my project";
await $`mkdir -p ${name} && cd ${name}`;
// 파이프
const files = await $`ls -la | grep ".ts" | wc -l`.text();
// 조건부 실행
const result = await $`git status`.nothrow();
if (result.exitCode !== 0) {
console.log("Not a git repo");
}장점
- TypeScript 타입 안전성
- 자동 변수 이스케이프
- 크로스 플랫폼 호환
댓글 0