Skip to content

Commit 382ba8d

Browse files
prestonvanloonhansl
authored andcommitted
fix(@angular/cli): Throw error when no key provided for ng get
Close #5887
1 parent 17ae140 commit 382ba8d

File tree

2 files changed

+6
-1
lines changed
  • packages/@angular/cli/commands
  • tests/e2e/tests/commands/get

2 files changed

+6
-1
lines changed

packages/@angular/cli/commands/get.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface GetOptions {
1111

1212
const GetCommand = Command.extend({
1313
name: 'get',
14-
description: 'Get a value from the configuration.',
14+
description: 'Get a value from the configuration. Example: ng get [key]',
1515
works: 'everywhere',
1616

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

35+
if (!rawArgs[0]) {
36+
throw new SilentError('No key specified. Run "ng help get" for usage.');
37+
}
38+
3539
const value = config.get(rawArgs[0]);
3640

3741
if (value === null || value === undefined) {

tests/e2e/tests/commands/get/get.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {expectToFail} from '../../../utils/utils';
44
export default function() {
55
return Promise.resolve()
66
.then(() => expectToFail(() => ng('get', 'apps.zzz.prefix')))
7+
.then(() => expectToFail(() => ng('get')))
78
.then(() => ng('get', 'apps.0.prefix'))
89
.then(({ stdout }) => {
910
if (!stdout.match(/app/)) {

0 commit comments

Comments
 (0)