Skip to content

fix(@angular/cli): ng get: return whole config root when no path provided. #5887

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

Closed
wants to merge 8 commits into from
6 changes: 5 additions & 1 deletion packages/@angular/cli/commands/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 project.name',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prestonvanloon Please change this to match format eg. "ng new [name]".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

works: 'everywhere',

availableOptions: [
Expand All @@ -32,6 +32,10 @@ const GetCommand = Command.extend({
+ 'you need the --global argument.');
}

if (!rawArgs[0]) {
throw new SilentError('No key specified. Run "ng help get" for usage.');
}

const value = config.get(rawArgs[0]);

if (value === null || value === undefined) {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/tests/commands/get/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {expectToFail} from '../../../utils/utils';
export default function() {
return Promise.resolve()
.then(() => expectToFail(() => ng('get', 'apps.zzz.prefix')))
.then(() => expectToFail(() => ng('get', undefined)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be just ng('get') as ng get undefined seems to be working fine already as it is converted to string key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

.then(() => ng('get', 'apps.0.prefix'))
.then(({ stdout }) => {
if (!stdout.match(/app/)) {
Expand Down