This repository was archived by the owner on Sep 25, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ function fetchConfigSync(dirname, opts) {
186186 }
187187
188188 function setKey ( keyPath , value ) {
189- if ( typeof keyPath !== 'string' ) {
189+ if ( typeof keyPath !== 'string' && ! Array . isArray ( keyPath ) ) {
190190 throw InvalidKeyPath ( {
191191 keyPath : keyPath
192192 } ) ;
Original file line number Diff line number Diff line change @@ -248,10 +248,15 @@ test('config.set()', function (assert) {
248248 config . set ( 'key' , 'value' ) ;
249249 config . set ( 'nested.key' , 'value2' ) ;
250250 config . set ( 'nested.key3' , 'value3' ) ;
251-
252- assert . equal ( config . get ( 'key' ) , 'value' ) ;
253- assert . equal ( config . get ( 'nested.key' ) , 'value2' ) ;
254- assert . equal ( config . get ( 'nested.key3' ) , 'value3' ) ;
251+ config . set ( [ 'nested' , 'key4' ] , 'value4' ) ;
252+ config . set ( [ 'nested' , 'key.with.dots5' ] , 'value5' ) ;
253+
254+ assert . equal ( config . get ( 'key' ) , 'value' , 'flat key' ) ;
255+ assert . equal ( config . get ( 'nested.key' ) , 'value2' , 'nested key' ) ;
256+ assert . equal ( config . get ( 'nested.key3' ) , 'value3' , 'child nested key' ) ;
257+ assert . equal ( config . get ( 'nested.key4' ) , 'value4' , 'array key' ) ;
258+ assert . equal ( config . get ( [ 'nested' , 'key.with.dots5' ] ) ,
259+ 'value5' , 'array key with dots' ) ;
255260
256261 assert . end ( ) ;
257262} ) ;
You can’t perform that action at this time.
0 commit comments