File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
tests/e2e/tests/commands/get Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -32,16 +32,12 @@ 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-
3935 const value = config . get ( rawArgs [ 0 ] ) ;
4036
4137 if ( value === null || value === undefined ) {
4238 throw new SilentError ( 'Value cannot be found.' ) ;
4339 } else if ( typeof value == 'object' ) {
44- console . log ( JSON . stringify ( value ) ) ;
40+ console . log ( JSON . stringify ( value , null , 2 ) ) ;
4541 } else {
4642 console . log ( value ) ;
4743 }
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ describe('Config', () => {
3434 stringKey : 'stringValue'
3535 } ) ;
3636
37+ expect ( JSON . parse ( JSON . stringify ( config . get ( ) ) ) ) . toEqual ( {
38+ requiredKey : 1 ,
39+ stringKeyDefault : 'defaultValue' ,
40+ stringKey : 'stringValue'
41+ } ) ;
3742 expect ( config . get ( 'requiredKey' ) ) . toEqual ( 1 ) ;
3843 expect ( config . get ( 'stringKey' ) ) . toEqual ( 'stringValue' ) ;
3944 expect ( config . get ( 'booleanKey' ) ) . toEqual ( undefined ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ export class CliConfig<JsonType> {
3939 return this . _config . $$alias ( path , newPath ) ;
4040 }
4141
42- get ( jsonPath : string ) {
42+ get ( jsonPath ?: string ) {
43+ if ( ! jsonPath ) {
44+ return this . _config . $$root ( ) ;
45+ }
4346 return this . _config . $$get ( jsonPath ) ;
4447 }
4548
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import {expectToFail} from '../../../utils/utils';
44export default function ( ) {
55 return Promise . resolve ( )
66 . then ( ( ) => expectToFail ( ( ) => ng ( 'get' , 'apps.zzz.prefix' ) ) )
7- . then ( ( ) => expectToFail ( ( ) => ng ( 'get' ) ) )
7+ . then ( ( ) => ng ( 'get' ) )
88 . then ( ( ) => ng ( 'get' , 'apps.0.prefix' ) )
99 . then ( ( { stdout } ) => {
1010 if ( ! stdout . match ( / a p p / ) ) {
You can’t perform that action at this time.
0 commit comments