Repository navigation
Honor --fail-on-error when --silent is enabled - #763
Open
ZainnQureshii wants to merge 1 commit into
Open
ZainnQureshii wants to merge 1 commit into
ZainnQureshii wants to merge 1 commit into
Conversation
The failOnError exit check sat inside the if (!options.silent) block that prints the run summary, so a silent run whose transform threw still exited 0. Move the check after the output block; error counting already happens in silent mode.
🦋 Changeset detectedLatest commit: 406710f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@ZainnQureshii is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Summary
--fail-on-errorhas no effect when--silentis also passed: a run whose transform throws still exits 0, so a CI job or script using both flags treats the failed codemod as a success.The cause is in
src/Runner.js. ThefailOnErrorexit check sits inside theif (!options.silent)block that prints the summary, so silent mode skips it along with the output:The error count is still kept in silent mode (
fileCountersis updated by the worker messages regardless ofsilent), so the fix moves the existing check out of the output block and leaves everything else as it was. The--fail-on-errorhelp text inbin/jscodeshift.jsdescribes a non-zero exit on errors with no exception for silent mode, and in the review of #416, which added the flag, its author noted that the check "didn't really belong in theif (!options.silent) {statement".Tests
New CLI cases in
bin/__tests__/jscodeshift-test.jsspawn the real binary, with and without--run-in-band:--fail-on-errorexits 1, both without and with--silent--silent --fail-on-errorprints nothing to stdout and exits 0--silentand no--fail-on-errorstill exits 0The small change to the
run()helper passes the child's exit code through so the tests can read it.Before the fix, the two
--silent=trueerror cases fail (Expected: 1, Received: 0), one per worker mode; after it, all eight pass. The fullyarn testsuite passes.A patch changeset is included.
Separately, the
--silenthelp text says "do not write to stdout or stderr", but transform errors are still printed in silent mode (log.errorinsrc/Runner.jschecks onlyverbose), and the error tests above rely on that output. This PR leaves that behaviour and the help text alone.Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code