Skip to content

[rush] rush list --json outputs non-JSON output when a lockfile is created or deleted #5406

@TAGraves

Description

@TAGraves

Summary

If you create or delete your lockfile and run rush list --json, the following is output to stdout:

Lockfile was created or deleted. Assuming all projects are affected.
{
  "projects": [
     ...
  ]
}

This breaks automation that attempts to pipe the result of rush list --json to a tool like jq since the first line is not JSON.

Repro steps

  1. Delete a lockfile
  2. Commit
  3. Re-add the lockfile
  4. Run rush list --json --impacted-by git:$COMMIT_SHA_WHERE_LOCKFILE_DOES_NOT_EXIST

Expected result: Only JSON is output to stdout. Since the error is a useful one, perhaps it should be output to stderr to preserve the ability to pipe the JSON to jq?

Actual result: The message "Lockfile was created or deleted. Assuming all projects are affected." is printed to stdout before the JSON is printed.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.153.2
rushVersion from rush.json? 5.153.2
useWorkspaces from rush.json? No
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? 22.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: easyProbably a quick fix. Want to contribute? :-)help wantedIf you're looking to contribute, this issue is a good place to start!

    Type

    No type

    Projects

    Status

    Low priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions