fix(cli): keep json preflight stdout machine-readable

This commit is contained in:
Altay
2026-02-23 12:34:10 +03:00
committed by Peter Steinberger
parent 493ebb915b
commit 9e4a366ee6
7 changed files with 260 additions and 11 deletions

View File

@@ -39,14 +39,27 @@ async function getConfigSnapshot() {
export async function ensureConfigReady(params: {
runtime: RuntimeEnv;
commandPath?: string[];
suppressDoctorStdout?: boolean;
}): Promise<void> {
const commandPath = params.commandPath ?? [];
if (!didRunDoctorConfigFlow && shouldMigrateStateFromPath(commandPath)) {
didRunDoctorConfigFlow = true;
await loadAndMaybeMigrateDoctorConfig({
options: { nonInteractive: true },
confirm: async () => false,
});
const runDoctorConfigFlow = async () =>
loadAndMaybeMigrateDoctorConfig({
options: { nonInteractive: true },
confirm: async () => false,
});
if (!params.suppressDoctorStdout) {
await runDoctorConfigFlow();
} else {
const originalStdoutWrite = process.stdout.write;
process.stdout.write = ((() => true) as unknown) as typeof process.stdout.write;
try {
await runDoctorConfigFlow();
} finally {
process.stdout.write = originalStdoutWrite;
}
}
}
const snapshot = await getConfigSnapshot();