diff --git a/packages/angular/cli/commands/config-impl.ts b/packages/angular/cli/commands/config-impl.ts index 717e67aae9a4..7e7b242ac926 100644 --- a/packages/angular/cli/commands/config-impl.ts +++ b/packages/angular/cli/commands/config-impl.ts @@ -80,7 +80,7 @@ function normalizeValue(value: string | undefined | boolean | number): JsonValue return +valueString; } - return value ?? undefined; + return parseJson(valueString) ?? value ?? undefined; } export class ConfigCommand extends Command { diff --git a/tests/legacy-cli/e2e/tests/commands/config/config-set.ts b/tests/legacy-cli/e2e/tests/commands/config/config-set.ts index e4c794c81d2c..26bf399763a6 100644 --- a/tests/legacy-cli/e2e/tests/commands/config/config-set.ts +++ b/tests/legacy-cli/e2e/tests/commands/config/config-set.ts @@ -15,14 +15,13 @@ export default async function () { throw new Error(`Expected "yarn", received "${JSON.stringify(stdout2)}".`); } - await ng('config', 'schematics.@schematics/angular:component.style', 'css'); - const { stdout: stdout3 } = await ng('config', '@schematics/angular:component.style'); - if (!stdout2.includes('css')) { - throw new Error(`Expected "css", received "${JSON.stringify(stdout3)}".`); + await ng('config', 'schematics', '{"@schematics/angular:component":{"style": "scss"}}'); + const { stdout: stdout3 } = await ng('config', 'schematics.@schematics/angular:component.style'); + if (!stdout3.includes('scss')) { + throw new Error(`Expected "scss", received "${JSON.stringify(stdout3)}".`); } - const { stderr } = await ng('config', 'schematics', 'undefined'); - if (!stderr.includes('Value cannot be found.')) { - throw new Error(`Expected "Value cannot be found", received "${JSON.stringify(stderr)}".`); - } + await ng('config', 'schematics'); + await ng('config', 'schematics', 'undefined'); + await expectToFail(() => ng('config', 'schematics')); }