11'use strict'
22
33const promisify = require ( 'promisify-es6' )
4- const _get = require ( 'lodash.get' )
5- const _has = require ( 'lodash.has' )
6- const _set = require ( 'lodash.set' )
74
85module . exports = function config ( self ) {
96 return {
@@ -13,42 +10,10 @@ module.exports = function config (self) {
1310 key = undefined
1411 }
1512
16- if ( ! key ) {
17- return self . _repo . config . get ( callback )
18- }
19-
20- if ( typeof key !== 'string' ) {
21- return callback ( new Error ( 'Invalid key type' ) )
22- }
23-
24- self . _repo . config . get ( ( err , config ) => {
25- if ( err ) {
26- return callback ( err )
27- }
28- if ( _has ( config , key ) ) {
29- const value = _get ( config , key , undefined )
30- callback ( null , value )
31- } else {
32- callback ( new Error ( 'Key does not exist in config' ) )
33- }
34- } )
13+ return self . _repo . config . get ( key , callback )
3514 } ) ,
3615 set : promisify ( ( key , value , callback ) => {
37- if ( ! key || typeof key !== 'string' ) {
38- return callback ( new Error ( 'Invalid key type' ) )
39- }
40-
41- if ( value === undefined || Buffer . isBuffer ( value ) ) {
42- return callback ( new Error ( 'Invalid value type' ) )
43- }
44-
45- self . _repo . config . get ( ( err , config ) => {
46- if ( err ) {
47- return callback ( err )
48- }
49- _set ( config , key , value )
50- self . config . replace ( config , callback )
51- } )
16+ self . _repo . config . set ( key , value , callback )
5217 } ) ,
5318 replace : promisify ( ( config , callback ) => {
5419 self . _repo . config . set ( config , callback )
0 commit comments