Scripts can compute an exit decision before actually calling process.exit.

Exit Code Plan

exit_plan.ts
type CheckSummary = {
    failed: number;
    exitCode: number;
};

function planExit(failed: number): CheckSummary {
    return {
        failed,
        exitCode: failed === 0 ? 0 : 1
    };
}

const failedChecks: number = ;
const summary: CheckSummary = planExit(failedChecks);

console.log(`failed=${summary.failed};exit=${summary.exitCode}`);
type CheckSummary = {
    failed: number;
    exitCode: number;
};

function planExit(failed: number): CheckSummary {
    return {
        failed,
        exitCode: failed === 0 ? 0 : 1
    };
}

const failedChecks: number = ;
const summary: CheckSummary = planExit(failedChecks);

console.log(`failed=${summary.failed};exit=${summary.exitCode}`);
exit decision Calculating an exit code as data keeps the core logic testable and easy to trace.