| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 382ba8d commit a5d8bc1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,16 +32,12 @@ const GetCommand = Command.extend({ | |||
| 32 | 32 | + 'you need the --global argument.'); | |
| 33 | 33 | } | |
| 34 | 34 | ||
| 35 | - if (!rawArgs[0]) { | ||
| 36 | - throw new SilentError('No key specified. Run "ng help get" for usage.'); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | 35 | const value = config.get(rawArgs[0]); | |
| 40 | 36 | ||
| 41 | 37 | if (value === null || value === undefined) { | |
| 42 | 38 | throw new SilentError('Value cannot be found.'); | |
| 43 | 39 | } else if (typeof value == 'object') { | |
| 44 | - console.log(JSON.stringify(value)); | ||
| 40 | + console.log(JSON.stringify(value, null, 2)); | ||
| 45 | 41 | } else { | |
| 46 | 42 | console.log(value); | |
| 47 | 43 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,11 @@ describe('Config', () => { | |||
| 34 | 34 | stringKey: 'stringValue' | |
| 35 | 35 | }); | |
| 36 | 36 | ||
| 37 | + expect(JSON.parse(JSON.stringify(config.get()))).toEqual({ | ||
| 38 | + requiredKey: 1, | ||
| 39 | + stringKeyDefault: 'defaultValue', | ||
| 40 | + stringKey: 'stringValue' | ||
| 41 | + }); | ||
| 37 | 42 | expect(config.get('requiredKey')).toEqual(1); | |
| 38 | 43 | expect(config.get('stringKey')).toEqual('stringValue'); | |
| 39 | 44 | expect(config.get('booleanKey')).toEqual(undefined); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,10 @@ export class CliConfig<JsonType> { | |||
| 39 | 39 | return this._config.$$alias(path, newPath); | |
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | - get(jsonPath: string) { | ||
| 42 | + get(jsonPath?: string) { | ||
| 43 | + if (!jsonPath) { | ||
| 44 | + return this._config.$$root(); | ||
| 45 | + } | ||
| 43 | 46 | return this._config.$$get(jsonPath); | |
| 44 | 47 | } | |
| 45 | 48 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import {expectToFail} from '../../../utils/utils'; | |||
| 4 | 4 | export default function() { | |
| 5 | 5 | return Promise.resolve() | |
| 6 | 6 | .then(() => expectToFail(() => ng('get', 'apps.zzz.prefix'))) | |
| 7 | - .then(() => expectToFail(() => ng('get'))) | ||
| 7 | + .then(() => ng('get')) | ||
| 8 | 8 | .then(() => ng('get', 'apps.0.prefix')) | |
| 9 | 9 | .then(({ stdout }) => { | |
| 10 | 10 | if (!stdout.match(/app/)) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments