Skip to content

Commit

Permalink
fix(@angular/cli): Throw error when no key provided for ng get
Browse files Browse the repository at this point in the history
Close #5887
  • Loading branch information
prestonvanloon authored and hansl committed May 9, 2017
1 parent 17ae140 commit 382ba8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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 [key]',
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')))
.then(() => ng('get', 'apps.0.prefix'))
.then(({ stdout }) => {
if (!stdout.match(/app/)) {
Expand Down

0 comments on commit 382ba8d

Please sign in to comment.