From 791a5914df2b4fdadbbe7e5b3bca5023ee2bf824 Mon Sep 17 00:00:00 2001 From: Shell Turner Date: Wed, 1 Oct 2014 18:13:37 +0200 Subject: [PATCH] Move config.js into the Shout home directory by default --- config.js | 4 ---- src/helper.js | 12 ++++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/config.js b/config.js index 3d46aa7..21681a8 100644 --- a/config.js +++ b/config.js @@ -187,7 +187,3 @@ module.exports = { certificate: "" } }; - -if ("SHOUT_CONFIG" in process.env) { - module.exports = require(process.env.SHOUT_CONFIG); -} diff --git a/src/helper.js b/src/helper.js index d616592..9c5b11a 100644 --- a/src/helper.js +++ b/src/helper.js @@ -1,13 +1,21 @@ +var fs = require("fs"); var path = require("path"); var Helper = module.exports = { getConfig: function () { - return require(path.resolve(__dirname, "..", "config")); + var filename = process.env.SHOUT_CONFIG; + if(!filename || !fs.exists(filename)) { + filename = this.resolveHomePath("config.js"); + if(!fs.exists(filename)) { + filename = path.resolve(__dirname, "..", "config"); + } + } + return require(filename); }, getHomeDirectory: function () { return ( - this.getConfig().home + (process.env.SHOUT_CONFIG && fs.exists(process.env.SHOUT_CONFIG) && this.getConfig().home) || process.env.SHOUT_HOME || path.resolve(process.env.HOME, ".shout") );