diff --git a/lib/configly.js b/lib/configly.js index bfe4b2a..acac9d5 100644 --- a/lib/configly.js +++ b/lib/configly.js @@ -1,4 +1,4 @@ -var merge = require('deeply') +var clone = require('deeply') , getCacheKey = require('./get_cache_key.js') ; @@ -19,7 +19,7 @@ function configly(options) // create new running context with custom options // fallback to default directories - context = this.new(merge(options || {})); + context = this.new(clone(options || {})); // prepare cache key cacheKey = getCacheKey.call(context); @@ -31,5 +31,8 @@ function configly(options) // return immutable copy // always return object here - return merge(this._cache[cacheKey] || {}); + return clone.call({ + useCustomTypeOf: clone.behaviors.useCustomTypeOf, + 'typeof': context.mergeTypeOf + }, this._cache[cacheKey] || {}); } diff --git a/test/fixtures/expected/env_vars_modifiers_custom.js b/test/fixtures/expected/env_vars_modifiers_custom.js index c2c7e1d..11ceb2d 100644 --- a/test/fixtures/expected/env_vars_modifiers_custom.js +++ b/test/fixtures/expected/env_vars_modifiers_custom.js @@ -1,7 +1,7 @@ var moment = require('moment'); var datetime = moment.utc('2016-01-01T00:00:00'); -var date = new Date('Fri Jan 01 2016 00:00:00 GMT-0800'); +var date = new Date('Fri Jan 01 2016 00:00:00'); var combinedDate = new Date('Thu Dec 31 2015 16:00:00 GMT-0800'); module.exports = { diff --git a/test/test-env_vars_modifiers.js b/test/test-env_vars_modifiers.js index adb62f6..ffcb6be 100644 --- a/test/test-env_vars_modifiers.js +++ b/test/test-env_vars_modifiers.js @@ -51,5 +51,6 @@ test('treated environment variables with modifiers', function(t) delete process.env['WITHOUT_ENV']; configObj = config({ directories: configDir }); + t.deepEqual(configObj, expected, 'expects to get right config object'); });