Permalink
Browse files

Added NODE_CONFIG_DIR environment variable

  • Loading branch information...
Loren West
Loren West committed Jan 17, 2012
1 parent 0aee036 commit 23f012f8806a34faefb874c3181106cc49a9a6d4
Showing with 15 additions and 48 deletions.
  1. +7 −0 History.md
  2. +0 −4 config/default.coffee
  3. +0 −10 config/default.js
  4. +0 −8 config/default.json
  5. +0 −9 config/default.yaml
  6. +0 −6 config/runtime.json
  7. +0 −4 config/test.yaml
  8. +4 −3 lib/config.js
  9. +4 −4 test/1-protected-test.js
View
@@ -1,3 +1,10 @@
+0.4.10 / 2012-01-18
+===================
+
+ * Made sure the CONFIG object is a shared singleton
+ * Added NODE_CONFIG_DIR environment variable to point to a different directory
+ * Added tests and documentation for the above
+
0.4.9 / 2012-01-06
==================
View
@@ -1,4 +0,0 @@
-module.exports =
- AnotherModule: parm3: "value3"
- Customers:
- dbName: "from_default_coffee"
View
@@ -1,10 +0,0 @@
-// Common configuration parameters
-module.exports = {
- TestModule: {
- parm1:"value1"
- },
- Customers: {
- dbHost:'base',
- dbName:'from_default_js'
- }
-};
View
@@ -1,8 +0,0 @@
-{
- "Customers": {
- "dbName":"from_default_json"
- },
- "AnotherModule": {
- "parm1":"value1"
- }
-}
View
@@ -1,9 +0,0 @@
-# Example of the baseline configuration in YAML
-
-Customers:
- dbPort: 5984
- dbName: from_default_yaml
-
-AnotherModule:
- parm2: value2
-
View
@@ -1,6 +0,0 @@
-{
- "Customers": {
- "dbName": "override_from_runtime_json"
- },
- "watchThisValue": 54485
-}
View
@@ -1,4 +0,0 @@
-# This is loaded if $NODE_ENV=test
-
-Customers:
- dbPort: 5999
View
@@ -8,8 +8,9 @@ var Sys = require('sys'),
// Static members
var DEFAULT_CLONE_DEPTH = 6,
FILE_WATCHER_INTERVAL = 3000,
- CONFIG_PATH = process.cwd() + '/config/',
- runtimeJsonFilename = CONFIG_PATH + 'runtime.json',
+ DIR = 'NODE_CONFIG_DIR',
+ CONFIG_DIR = process.env[DIR] ? process.env[DIR] : process.cwd() + '/config/',
+ runtimeJsonFilename = CONFIG_DIR + 'runtime.json',
originalConfig = null, // Not including the runtime.json values
runtimeJson = {}, // Current runtimeJson extensions
isQueuedForPersistence = false,
@@ -568,7 +569,7 @@ Config.prototype._loadFileConfigs = function() {
baseNames.forEach(function(baseName) {
extNames.forEach(function(extName) {
// Try merging the config object into this object
- var fullFilename = CONFIG_PATH + baseName + '.' + extName;
+ var fullFilename = CONFIG_DIR + baseName + '.' + extName;
var configObj = t._parseFile(fullFilename);
if (configObj) {
t._extendDeep(t, configObj);
View
@@ -4,6 +4,9 @@
* @module test
*/
+// Change the configuration directory for testing
+process.env.NODE_CONFIG_DIR = __dirname;
+
// Hardcode $NODE_ENV=test for testing
process.env.NODE_ENV='test';
@@ -12,9 +15,6 @@ var CONFIG = require('../lib/config');
var vows = require('vows');
var assert = require('assert');
-// These tests require the directory to be the root of the node-config project
-process.chdir(__dirname + '/..');
-
/**
* <p>Tests for underlying node-config utilities. To run type:</p>
* <pre>npm test config</pre>
@@ -254,7 +254,7 @@ exports.PrivateTest = vows.describe('Protected (hackable) utilities test').addBa
'_parseFile() tests': {
topic: function() {
- return CONFIG._parseFile(__dirname + '/../config/default.yaml');
+ return CONFIG._parseFile(__dirname + '/config/default.yaml');
},
'The function exists': function() {
assert.isFunction(CONFIG._parseFile);

0 comments on commit 23f012f

Please sign in to comment.