When config is overriden with null don't merge

Fixes #146 and also fixes strongloop/loopback-component-explorer#51
This commit is contained in:
Farid Neshat 2016-01-08 22:54:15 +08:00
parent a5b888a719
commit d850560a18
2 changed files with 19 additions and 1 deletions

View File

@ -266,7 +266,7 @@ function mergeSingleItemOrProperty(target, config, key, fullKey) {
return mergeArrays(origValue, newValue, fullKey);
}
if (typeof origValue === 'object') {
if (newValue !== null && typeof origValue === 'object') {
return mergeObjects(origValue, newValue, fullKey);
}

View File

@ -756,6 +756,24 @@ describe('executor', function() {
appdir.resolve('components/test-component/index.js'));
});
it('disable component if overrided by production configuration', function() {
appdir.writeConfigFileSync('component-config.json', {
'./components/test-component': {}
});
appdir.writeConfigFileSync('component-config.production.json', {
'./components/test-component': null
});
appdir.writeFileSync('components/test-component/index.js',
'module.exports = ' +
'function(app, options) { app.componentOptions = options; }');
boot(app, { appRootDir: appdir.PATH, env: 'production' });
expect(Object.keys(require.cache)).to.not.include(
appdir.resolve('components/test-component/index.js'));
});
it('configures middleware (that requires `this`)', function(done) {
var passportPath = require.resolve('./fixtures/passport');