diff --git a/packages/@angular/cli/commands/config.ts b/packages/@angular/cli/commands/config.ts index eb9a37ceb1..0490efbb54 100644 --- a/packages/@angular/cli/commands/config.ts +++ b/packages/@angular/cli/commands/config.ts @@ -1,4 +1,5 @@ import { + InvalidJsonCharacterException, JsonArray, JsonObject, JsonParseMode, @@ -150,7 +151,15 @@ function normalizeValue(value: string, path: string): JsonValue { } if (typeof value === 'string') { - return parseJson(value, JsonParseMode.Loose); + try { + return parseJson(value, JsonParseMode.Loose); + } catch (e) { + if (e instanceof InvalidJsonCharacterException && !value.startsWith('{')) { + return value; + } else { + throw e; + } + } } return value; diff --git a/tests/e2e/tests/commands/config/config-get.ts b/tests/e2e/tests/commands/config/config-get.ts index 0ad7c4eded..a5abd6ad6f 100644 --- a/tests/e2e/tests/commands/config/config-get.ts +++ b/tests/e2e/tests/commands/config/config-get.ts @@ -1,5 +1,5 @@ -import {ng} from '../../../utils/process'; -import {expectToFail} from '../../../utils/utils'; +import { ng } from '../../../utils/process'; +import { expectToFail } from '../../../utils/utils'; export default function() { @@ -12,9 +12,6 @@ export default function() { throw new Error(`Expected "false", received "${JSON.stringify(stdout)}".`); } }) - .then(() => expectToFail(() => { - return ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN'); - })) .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle', 'true')) .then(() => ng('config', 'schematics.@schematics/angular.component.inlineStyle')) .then(({ stdout }) => { diff --git a/tests/e2e/tests/commands/config/config-global.ts b/tests/e2e/tests/commands/config/config-global.ts index acb462e848..0df85d8906 100644 --- a/tests/e2e/tests/commands/config/config-global.ts +++ b/tests/e2e/tests/commands/config/config-global.ts @@ -1,9 +1,8 @@ -import {ng} from '../../../utils/process'; -import {expectToFail} from '../../../utils/utils'; -import { expectFileToExist } from '../../../utils/fs'; -import * as path from 'path'; import { homedir } from 'os'; -import { deleteFile } from '../../../utils/fs'; +import * as path from 'path'; +import { deleteFile, expectFileToExist } from '../../../utils/fs'; +import { ng } from '../../../utils/process'; +import { expectToFail } from '../../../utils/utils'; export default function() { @@ -16,9 +15,10 @@ export default function() { throw new Error(`Expected "false", received "${JSON.stringify(stdout)}".`); } }) - .then(() => expectToFail(() => { - return ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN'); - })) + // This test requires schema querying capabilities + // .then(() => expectToFail(() => { + // return ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN'); + // })) .then(() => ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'true')) .then(() => ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle')) .then(({ stdout }) => { diff --git a/tests/e2e/tests/commands/config/config-set-enum-check.ts b/tests/e2e/tests/commands/config/config-set-enum-check.ts index 4eafa5584d..aabf758930 100644 --- a/tests/e2e/tests/commands/config/config-set-enum-check.ts +++ b/tests/e2e/tests/commands/config/config-set-enum-check.ts @@ -1,13 +1,21 @@ -import {ng} from '../../../utils/process'; -import {expectToFail} from '../../../utils/utils'; +import { ng } from '../../../utils/process'; +import { expectToFail } from '../../../utils/utils'; -export default function() { - return Promise.resolve() - .then(() => expectToFail(() => ng('config', 'schematics.@schematics/angular.component.aaa', 'bbb'))) - .then(() => expectToFail(() => ng( - 'config', - 'schematics.@schematics/angular.component.viewEncapsulation', - 'bbb' - ))) - .then(() => ng('config', 'schematics.@schematics/angular.component.viewEncapsulation', '"Emulated"')); +export default async function() { + + // These tests require schema querying capabilities + // .then(() => expectToFail( + // () => ng('config', 'schematics.@schematics/angular.component.aaa', 'bbb')), + // ) + // .then(() => expectToFail(() => ng( + // 'config', + // 'schematics.@schematics/angular.component.viewEncapsulation', + // 'bbb', + // ))) + + await ng( + 'config', + 'schematics.@schematics/angular.component.viewEncapsulation', + 'Emulated', + ); } diff --git a/tests/e2e/tests/commands/config/config-set-prefix.ts b/tests/e2e/tests/commands/config/config-set-prefix.ts index 089242ae63..9040506491 100644 --- a/tests/e2e/tests/commands/config/config-set-prefix.ts +++ b/tests/e2e/tests/commands/config/config-set-prefix.ts @@ -1,23 +1,14 @@ -import {ng} from '../../../utils/process'; -import {expectToFail} from '../../../utils/utils'; -import * as fs from 'fs'; +import { ng } from '../../../utils/process'; +import { expectToFail } from '../../../utils/utils'; export default function() { - return; - return Promise.resolve() - .then(() => expectToFail(() => ng('config', 'apps.zzz.prefix'))) - .then(() => ng('config', 'apps.0.prefix' , 'new-prefix')) - .then(() => ng('config', 'apps.0.prefix')) + .then(() => expectToFail(() => ng('config', 'schematics.@schematics/angular.component.prefix'))) + .then(() => ng('config', 'schematics.@schematics/angular.component.prefix' , 'new-prefix')) + .then(() => ng('config', 'schematics.@schematics/angular.component.prefix')) .then(({ stdout }) => { if (!stdout.match(/new-prefix/)) { throw new Error(`Expected "new-prefix", received "${JSON.stringify(stdout)}".`); } - }) - .then(() => { - const tsLint = JSON.parse(fs.readFileSync(process.cwd() + '/tslint.json', 'utf8')); - if (tsLint.rules['component-selector'][2] !== 'new-prefix') { - throw new Error(`Expected "new-prefix" Found: ${tsLint.rules['component-selector'][2]}.`); - } }); }