Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: --no-defaults flag is ignore on yarn config when the --json flag is present #6341

Open
1 task
chrisbodhi opened this issue Jun 13, 2024 · 2 comments · May be fixed by #6635
Open
1 task

[Bug?]: --no-defaults flag is ignore on yarn config when the --json flag is present #6341

chrisbodhi opened this issue Jun 13, 2024 · 2 comments · May be fixed by #6635
Labels
bug Something isn't working

Comments

@chrisbodhi
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

Running yarn config --no-defaults --json returns in a JSON format (expected) all of the config options (unexpected). I expected the yarn config command, with both flags, to return only the non-default settings in a JSON format.

To reproduce

yarn config --json --no-defaults

Environment

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 20.7.0 - /private/var/folders/lc/yqxr0r45775_2f5mfzyj9x2c0000gp/T/xfs-fb1e8fe6/node
    Yarn: 4.2.2 - /private/var/folders/lc/yqxr0r45775_2f5mfzyj9x2c0000gp/T/xfs-fb1e8fe6/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.7.0/bin/npm

Additional context

No response

@chrisbodhi chrisbodhi added the bug Something isn't working label Jun 13, 2024
@chrisbodhi chrisbodhi changed the title [Bug]: --no-defaults flag is ignore on yarn config when the --json flag is present [Bug?]: --no-defaults flag is ignore on yarn config when the --json flag is present Jun 14, 2024
@sparrowt
Copy link

sparrowt commented Dec 17, 2024

Yes I noticed this unexpected behaviour too - this bug seems to occur because this.noDefaults is only checked here which is in the else block of the if (this.json) { so it is not checked when emitting the JSON output.

sparrowt added a commit to sparrowt/berry that referenced this issue Dec 17, 2024
As documented here https://yarnpkg.com/cli/config you would expect `--no-defaults` to omit defaults even when `--json` is also specified.

This commit fixes that behaviour to be as expected.
@sparrowt sparrowt linked a pull request Dec 17, 2024 that will close this issue
3 tasks
@sparrowt
Copy link

I've proposed a fix here #6635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants