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

Issue #769, added code which attempts to load the configuration file … #912

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}