ipal-doctor: never write first-seen dates when CI is set

The CLI ignored CI (writeSeen was only !sites && !json); docs and comments
already said "not in CI". shouldWriteSeen() + test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-24 00:01:18 +01:00
co-authored by Claude Opus 5.5
parent 36f8f69f82
commit 5cd0224ebd
2 changed files with 19 additions and 2 deletions
+9 -1
View File
@@ -26,6 +26,14 @@ export const DOCTOR_USAGE = `Usage: ipal-doctor [dir] [options]
Exit: 0 ok · 1 findings at or above --fail-on · 2 could not run · 3 a rule crashed
Silence a rule with a reason in ipal-doctor.json — docs/doctor.md`
/**
* Whether this run stores first-seen dates in ipal-doctor.json: not with --sites or --json, and
* never when CI is set (a CI run must not change a tracked file).
*/
export function shouldWriteSeen(args: { json?: boolean; sites?: unknown }, env: Record<string, string | undefined> = process.env): boolean {
return !args.sites && !args.json && !env.CI
}
const RANK: Record<DoctorSeverity, number> = { error: 3, info: 1, warning: 2 }
type Args = {
@@ -132,7 +140,7 @@ export async function runDoctorCli(argv: string[], { cwd = process.cwd(), log =
skip: args.skip,
staging: args.staging,
url: args.sites ? undefined : args.url,
writeSeen: !args.sites && !args.json,
writeSeen: shouldWriteSeen(args),
}),
)
}