Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Issue #769, added code which attempts to load the configuration file …
Browse files Browse the repository at this point in the history
…passed in on the command line. If not found, tries ./conf.js. Previously, it was only trying ./conf.js (#912)
  • Loading branch information
haxwell authored and DeviaVir committed Dec 18, 2017
1 parent ccf9811 commit d36aed8
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ var glob = require('glob')

module.exports = function (cb) {
var zenbot = require('./')()
try {
var c = require('./conf')
}
catch (e) {
c = {}
}
var c = getConfiguration()

var defaults = require('./conf-sample')
Object.keys(defaults).forEach(function (k) {
if (typeof c[k] === 'undefined') {
Expand Down Expand Up @@ -50,4 +46,32 @@ module.exports = function (cb) {
withMongo()
}
})

function getConfiguration() {
var conf = undefined

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

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

if (found) {
try {
conf = require(_allArgs[0])
} catch (ee) {
conf = require('./conf')
}
} else {
conf = require('./conf')
}
}
catch (e) {
conf = {}
}

return conf
}
}

0 comments on commit d36aed8

Please sign in to comment.