2025-11-25 03:42:12 +01:00
|
|
|
import { runExec } from "../process/exec.js";
|
|
|
|
|
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
|
|
|
|
|
|
|
|
|
export async function ensureBinary(
|
2025-11-26 00:53:53 +01:00
|
|
|
name: string,
|
|
|
|
|
exec: typeof runExec = runExec,
|
|
|
|
|
runtime: RuntimeEnv = defaultRuntime,
|
2025-11-25 03:42:12 +01:00
|
|
|
): Promise<void> {
|
2025-11-26 00:53:53 +01:00
|
|
|
// 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);
|
|
|
|
|
});
|
2025-11-25 03:42:12 +01:00
|
|
|
}
|