From 7ac94a5304215158d925e3b7104b666c1339cea0 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sun, 4 Dec 2016 18:14:35 -0800 Subject: [PATCH] Resolve CONFIG_DIR to absolute path --- lib/config.coffee | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/config.coffee b/lib/config.coffee index 7b927dd..2137822 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -19,7 +19,7 @@ path = require 'path' common = require './common' options = { - CONFIG_DIR : {type : 'string', default : 'config'}, + CONFIG_DIR : {type : 'path', default : 'config'}, MONGODB_CONNECTION_URL : {type : 'string', default : 'mongodb://127.0.0.1/genieacs'}, REDIS_PORT : {type : 'int', default : 6379}, REDIS_HOST : {type : 'string', default : '127.0.0.1'}, @@ -80,6 +80,8 @@ setConfig = (name, value, commandLineArgument) -> String(val).trim().toLowerCase() in ['true', 'on', 'yes', '1'] when 'string' String(val) + when 'path' + path.resolve(val) else null @@ -126,14 +128,8 @@ for k, v of process.env setConfig(k, v) -# Find config dir -if exports.argv['--config-dir']? - allConfig.CONFIG_DIR = exports.argv['--config-dir'] -else if process.env['GENIEACS_CONFIG_DIR']? - allConfig.CONFIG_DIR = process.env['GENIEACS_CONFIG_DIR'] -else - allConfig.CONFIG_DIR = options.CONFIG_DIR.default - +# Use default config dir if none defined +setConfig('CONFIG_DIR', options['CONFIG_DIR'].default) # Configuration file for k, v of require(path.resolve(allConfig.CONFIG_DIR, 'config'))