Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/envious.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function envious () {
env = process.env.NODE_ENV;
if (this[env]) {
// environment matched
this[env].__proto__.valueOf = function(){ return env; }
return this[env];
} else {
// no environment matched
Expand All @@ -38,6 +39,7 @@ function envious () {
throw new Error('envious: no configuration found for default environment `' + this.default_env + '`');
} else if (this.default_env && this[this.default_env]) {
// return default
this[this.default_env].__proto__.valueOf = function(){ return env; }
return this[this.default_env];
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ assert.doesNotThrow(function() { envious.apply() });
console.log('test -- variable site_url should match that of the default set');
assert.equal(env.site_url, 'http://127.0.0.1/');

console.log('test -- testable against a string value matching environment name');
assert.equal(env, 'development');

console.log('test -- variable site_url should not match that of the production set');
assert.notEqual(env.site_url, 'http://zombo.com/');

Expand Down