[rush] Route lockfile-changed warning to stderr (fixes #5406)#5804
Open
LeSingh1 wants to merge 1 commit into
Open
[rush] Route lockfile-changed warning to stderr (fixes #5406)#5804LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
`rush list --json` writes `Lockfile was created or deleted. Assuming all projects are affected.` to stdout when the lockfile was added or removed in the diff range, which corrupts the JSON output and breaks pipes such as `rush list --json --impacted-by git:<sha> | jq .`. The information is useful diagnostic context, so rather than suppress it, route it through `terminal.writeWarningLine` (which writes to stderr) -- the standard CLI convention for warnings that should not pollute machine-readable stdout. Matches how the rest of this file already emits non-fatal diagnostics (see lines 418, 446, 458). Fixes microsoft#5406
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
rush list --jsoncorrupts its own JSON output when the lockfile was added or removed in the diff range:The first line is written to stdout, so the output is no longer parseable by
jqor any other tool consuming the JSON.Fix
Route both branches of the lockfile-status warning in
ProjectChangeAnalyzer.tsthroughterminal.writeWarningLine(which writes to stderr) rather thanterminal.writeLine. This is the standard CLI convention for warnings that should not pollute machine-readable stdout, and it matches how the rest of this file already emits non-fatal diagnostics (see existingwriteWarningLinecalls at lines 418, 446, 458 onmain).iclantongreen-lit a PR in the issue thread ("Probably pretty simple to fix. Are you interested in putting together a PR?").Changeset
Added a
patchchangeset for@microsoft/rushundercommon/changes/.Verification
I do not have a Rush-managed monorepo set up locally to demonstrate the before/after pipe, but the diff is a one-method swap (
writeLine→writeWarningLine) and the receiving terminal type already exposes the warning method (used elsewhere in the same file).Issue
Fixes #5406