refactor: modularize cli helpers

This commit is contained in:
Peter Steinberger
2025-11-25 03:42:12 +01:00
parent 5c5a103abb
commit a89d7319a9
14 changed files with 591 additions and 777 deletions

14
src/infra/binaries.ts Normal file
View File

@@ -0,0 +1,14 @@
import { runExec } from "../process/exec.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
export async function ensureBinary(
name: string,
exec: typeof runExec = runExec,
runtime: RuntimeEnv = defaultRuntime,
): Promise<void> {
// Abort early if a required CLI tool is missing.
await exec("which", [name]).catch(() => {
runtime.error(`Missing required binary: ${name}. Please install it.`);
runtime.exit(1);
});
}