Skip to content

Commit

Permalink
fix: fix merge config to default config
Browse files Browse the repository at this point in the history
use lodash merge to merge deep object
  • Loading branch information
tcnguyen committed Apr 18, 2018
1 parent 147670e commit 6d9943c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 8 deletions.
8 changes: 5 additions & 3 deletions packages/botfuel-dialog/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const fs = require('fs');
const path = require('path');
const { omitBy } = require('lodash');
const _ = require('lodash');
const logger = require('logtown')('Config');
const LoggerManager = require('./logger-manager');
const ConfigurationError = require('./errors/configuration-error');
Expand Down Expand Up @@ -108,11 +108,13 @@ const getComponentRoots = function (config) {
*/
const getConfiguration = (botConfig = {}) => {
// get the config by extending defaultConfig with botConfig
const config = Object.assign(
const config = _.merge(
defaultConfig,
omitBy(botConfig, (val, key) => !whitelist.includes(key)),
_.omitBy(botConfig, (val, key) => !whitelist.includes(key)),
);

Object.assign(defaultConfig);

config.brain.conversationDuration =
config.brain.conversationDuration || DEFAULT_CONVERSATION_DURATION;

Expand Down
1 change: 0 additions & 1 deletion packages/test-modules/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = {
modules: ['botfuel-module-sample'],
nlu: {
name: 'sample-module',
intentThreshold: 0.75,
nluSecretSauce: 43,
},
path: __dirname,
Expand Down
1 change: 0 additions & 1 deletion packages/test-qna/botfuel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = {
},
nlu: {
name: 'botfuel',
intentThreshold: 0.75,
qna: {
when: 'after',
},
Expand Down
1 change: 0 additions & 1 deletion packages/test-qna/shell-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
module.exports = {
nlu: {
name: 'botfuel',
intentThreshold: 0.75,
qna: {
when: 'after',
},
Expand Down
1 change: 0 additions & 1 deletion packages/test-qna/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = {
},
nlu: {
name: 'botfuel',
intentThreshold: 0.75,
qna: {},
},
logger: 'error',
Expand Down
1 change: 0 additions & 1 deletion packages/test-resolvers/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = {
logger: 'error',
nlu: {
name: 'custom',
intentThreshold: 0.75,
nluSecretSauce: 43,
},
path: __dirname,
Expand Down

0 comments on commit 6d9943c

Please sign in to comment.