Skip to content

Commit

Permalink
conf override fixes (DeviaVir#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophv authored and DeviaVir committed Feb 12, 2018
1 parent 5646d9e commit f5567e5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions boot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var _ = require('lodash')
var path = require('path')
var minimist = require('minimist')

module.exports = function (cb) {
var zenbot = require('./')
Expand Down Expand Up @@ -52,19 +54,13 @@ module.exports = function (cb) {
})

function getConfiguration() {
var args = minimist(process.argv.slice(3))
var conf = undefined

try {
var _allArgs = process.argv.slice()
var found = false

while (!found && _allArgs.length > 0) {
found = (_allArgs.shift() == '--conf')
}

if (found) {
if(!_.isUndefined(args.conf)){
try {
conf = require(_allArgs[0])
conf = require(path.resolve(process.cwd(), args.conf))
} catch (ee) {
console.log('Fall back to conf.js, ' + ee)
conf = require('./conf')
Expand All @@ -77,7 +73,8 @@ module.exports = function (cb) {
console.log('Fall back to sample-conf.js, ' + e)
conf = {}
}

return conf

// prevent modifying cached module with a clone
return _.cloneDeep(conf)
}
}

0 comments on commit f5567e5

Please sign in to comment.