feat(check): add --strict so a failed check exits non-zero - #193
Merged
Conversation
check is what anyone reaches for in a health-check script or a CI gate, and it always exited 0. An empty directory, a stack that is down, and a healthy project were indistinguishable to anything reading the exit status. --strict exits 1 when any check failed and reports the count. The default is unchanged, since this output has been parsed by scripts since before the flag existed. Results now go through a small Report rather than straight to console.log, so every check still runs before the exit decision: a gate that stops at the first problem hides the rest, and the whole picture is the reason to run check. Refs #166
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #166
#166 asks to "decide the
seamless checkexit-code question, here or in a linked issue". #192 took the other branch it offers (the smoke job asserts independently), so that job does not depend on this. This is the decision, sent separately because it is a user-facing CLI flag rather than a CI change, and it touches all thirteen check sites.The problem
From the issue, and reproduced:
An empty directory, a stack that is down, and a fully healthy project are indistinguishable to anything reading the exit status.
checkis exactly the command you would put in a health-check script, and it cannot be used in one.The fix
--strictexits 1 when any check failed, naming the count:Two decisions worth stating:
The default is unchanged. Anything parsing this output today keeps working, and a sudden non-zero exit would break it silently. That is why this is a flag rather than new default behaviour, as the issue suggests.
Every check still runs. Results go through a small
Reportthat counts failures instead of throwing, so--strictdecides the exit status only after the full report has printed. A gate that stops at the first problem hides the rest, and the whole picture is the reason to runcheckat all. There is a test for this: a project failing eight ways prints all eight and reports8 checks failed.The refactor
All thirteen pass/fail sites moved from bare
console.logtoreport.ok(...)/report.fail(message, remedy?). That is what makes the count possible, and it also collapses the repeated two-line "failure then remedy" pattern into one call.runChecktakesargssoindex.tscan pass the flag through; it defaults to[], so existing callers and tests are unaffected.Verification
npm run buildandnpm testpass, 916 tests. 5 new tests. Also checked against the real binary rather than only through mocks:helpTopics.tsdocuments the flag, per the convention in AGENTS.md that the help registry is the single source. README does not mentioncheckat all, so there is nothing to update there.