From fc2bf0f9cc5763ba0996f997bf7385d7f54428c7 Mon Sep 17 00:00:00 2001 From: Tom Sparrow <793763+sparrowt@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:44:04 +0000 Subject: [PATCH] Yarn config respect --no-defaults with --json (fixes #6341) 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. --- packages/plugin-essentials/sources/commands/config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/plugin-essentials/sources/commands/config.ts b/packages/plugin-essentials/sources/commands/config.ts index 895ca949fb5b..ffbe334b6fb0 100644 --- a/packages/plugin-essentials/sources/commands/config.ts +++ b/packages/plugin-essentials/sources/commands/config.ts @@ -76,6 +76,9 @@ export default class ConfigCommand extends BaseCommand { if (this.json) { for (const name of names) { + if (this.noDefaults && !configuration.sources.has(name)) + continue; + const data = configuration.settings.get(name); if (typeof data === `undefined`) report.reportError(MessageName.INVALID_CONFIGURATION_KEY, `No configuration key named "${name}"`);