Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(config): allow customizer for config.merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed May 26, 2017
1 parent feb4e40 commit c7ebade
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ class Config {
*
* @param {String} key
* @param {Object} defaultValues
* @param {Function} [customizer]
*
* @return {Object}
*/
merge (key, defaultValues) {
merge (key, defaultValues, customizer) {
const value = _.get(this._config, key, {})
return _.mergeWith(defaultValues, value, (base, value) => typeof (value) === 'undefined' ? base : value)
return _.mergeWith(defaultValues, value, customizer)
}

/**
Expand Down
5 changes: 5 additions & 0 deletions test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ test.group('Config', () => {
host: '127.0.0.1',
port: 3306
}
}, (obj, src, key) => {
if (key === 'connection') {
return src
}
})

assert.deepEqual(database, {
client: 'mysql',
connection: {}
Expand Down

0 comments on commit c7ebade

Please sign in to comment.