adon-config
Advanced tools
Comparing version 1.0.5 to 1.1.0
31
index.js
@@ -6,2 +6,3 @@ "use strict"; | ||
_ = require('lodash'), | ||
coffee_script = require('coffee-script'), | ||
self, | ||
@@ -38,15 +39,23 @@ singleton; | ||
load (module_root) { | ||
/** | ||
* Loads a configuration from an object or a configuration directory | ||
* @param source - the object instance of a configuration or the directory which follows the standard configuration structure | ||
*/ | ||
load (source) { | ||
try { | ||
let config_path = path.resolve(module_root+ '/config'); | ||
if (fs.statSync(config_path).isDirectory()) { | ||
let base_path = path.isAbsolute(config_path) ? config_path + '/' : config_path, | ||
default_path = base_path + 'default', | ||
environment = process.env.NODE_ENV || 'development', | ||
environment_path = base_path + 'env/' + environment.toLowerCase(); | ||
if (typeof source === 'object') { | ||
self.config = source; | ||
} else { | ||
let config_path = path.resolve(source + '/config'); | ||
if (fs.statSync(config_path).isDirectory()) { | ||
let base_path = path.isAbsolute(config_path) ? config_path + '/' : config_path, | ||
default_path = base_path + 'default', | ||
environment = process.env.NODE_ENV || 'development', | ||
environment_path = base_path + 'env/' + environment.toLowerCase(); | ||
loadConfigFile(default_path + '.json'); | ||
loadConfigFile(default_path + '.js'); | ||
loadConfigFile(environment_path + '.json'); | ||
loadConfigFile(environment_path + '.js'); | ||
loadConfigFile(default_path + '.json'); | ||
loadConfigFile(default_path + '.js'); | ||
loadConfigFile(environment_path + '.json'); | ||
loadConfigFile(environment_path + '.js'); | ||
} | ||
} | ||
@@ -53,0 +62,0 @@ } catch (err) { |
{ | ||
"name": "adon-config", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "This module is used for managing system configurations in cascading order.", | ||
@@ -20,2 +20,3 @@ "keywords": [ | ||
"dependencies": { | ||
"coffee-script": "^1.10.0", | ||
"lodash": "^4.11.1" | ||
@@ -22,0 +23,0 @@ }, |
40668
60
2
+ Addedcoffee-script@^1.10.0
+ Addedcoffee-script@1.12.7(transitive)