Only load config if it exists

This commit is contained in:
Pavel Djundik 2016-07-04 23:15:30 +03:00
parent 7ba11b8913
commit 08f197f912

View file

@ -1,6 +1,7 @@
var _ = require("lodash"); var _ = require("lodash");
var path = require("path"); var path = require("path");
var os = require("os"); var os = require("os");
var fs = require("fs");
var Helper = { var Helper = {
config: null, config: null,
@ -25,9 +26,11 @@ function setHome(homePath) {
this.USERS_PATH = path.join(this.HOME, "users"); this.USERS_PATH = path.join(this.HOME, "users");
// Reload config from new home location // Reload config from new home location
if (fs.existsSync(this.CONFIG_PATH)) {
var userConfig = require(this.CONFIG_PATH); var userConfig = require(this.CONFIG_PATH);
this.config = _.extend(this.config, userConfig); this.config = _.extend(this.config, userConfig);
} }
}
function getUserConfigPath(name) { function getUserConfigPath(name) {
return path.join(this.USERS_PATH, name + ".json"); return path.join(this.USERS_PATH, name + ".json");