1import { doctorReport, printDoctorReport } from "../tooling/diagnostics.ts";2import { childEnvironment } from "../tooling/environment.ts";34export async function validatedCommandEnvironment(): Promise<Record<string, string>> {5 const report = await doctorReport();6 if (report.blocked || !report.validation.ok) {7 printDoctorReport(report);8 console.error(9 "error: lofi preflight found blockers; apply the printed action and rerun the command",10 );11 Deno.exit(1);12 }13 for (const warning of report.validation.warnings) console.warn(`warning: ${warning}`);14 return childEnvironment(report.validation);15}1617export function exitOnFailure(exitCode: number, action: string): void {18 if (exitCode === 0) return;19 console.error(`error: ${action} failed; fix the first error above and rerun the same Deno task`);20 Deno.exit(exitCode);21}