diff --git a/packages/@angular/cli/commands/get.ts b/packages/@angular/cli/commands/get.ts index ee0bca96ab35..a0092f45f78f 100644 --- a/packages/@angular/cli/commands/get.ts +++ b/packages/@angular/cli/commands/get.ts @@ -11,7 +11,7 @@ export interface GetOptions { const GetCommand = Command.extend({ name: 'get', - description: 'Get a value from the configuration.', + description: 'Get a value from the configuration. Example: ng get [key]', works: 'everywhere', availableOptions: [ @@ -37,7 +37,7 @@ const GetCommand = Command.extend({ if (value === null || value === undefined) { throw new SilentError('Value cannot be found.'); } else if (typeof value == 'object') { - console.log(JSON.stringify(value)); + console.log(JSON.stringify(value, null, 2)); } else { console.log(value); } diff --git a/packages/@angular/cli/models/config/config.spec.ts b/packages/@angular/cli/models/config/config.spec.ts index 2c6c78eb8744..cf4a95862102 100644 --- a/packages/@angular/cli/models/config/config.spec.ts +++ b/packages/@angular/cli/models/config/config.spec.ts @@ -34,6 +34,11 @@ describe('Config', () => { stringKey: 'stringValue' }); + expect(JSON.parse(JSON.stringify(config.get()))).toEqual({ + requiredKey: 1, + stringKeyDefault: 'defaultValue', + stringKey: 'stringValue' + }); expect(config.get('requiredKey')).toEqual(1); expect(config.get('stringKey')).toEqual('stringValue'); expect(config.get('booleanKey')).toEqual(undefined); diff --git a/packages/@angular/cli/models/config/config.ts b/packages/@angular/cli/models/config/config.ts index 7370b1ff5766..e2698ea4cfca 100644 --- a/packages/@angular/cli/models/config/config.ts +++ b/packages/@angular/cli/models/config/config.ts @@ -39,7 +39,10 @@ export class CliConfig { return this._config.$$alias(path, newPath); } - get(jsonPath: string) { + get(jsonPath?: string) { + if (!jsonPath) { + return this._config.$$root(); + } return this._config.$$get(jsonPath); } diff --git a/tests/e2e/tests/commands/get/get.ts b/tests/e2e/tests/commands/get/get.ts index b66fb2e9ceb1..34c70b12f197 100644 --- a/tests/e2e/tests/commands/get/get.ts +++ b/tests/e2e/tests/commands/get/get.ts @@ -4,6 +4,7 @@ import {expectToFail} from '../../../utils/utils'; export default function() { return Promise.resolve() .then(() => expectToFail(() => ng('get', 'apps.zzz.prefix'))) + .then(() => ng('get')) .then(() => ng('get', 'apps.0.prefix')) .then(({ stdout }) => { if (!stdout.match(/app/)) {