Skip to content

Commit

Permalink
[api] Add options.hideEnv {key:boolean_hide,} to hide default env values
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeck committed Aug 23, 2011
1 parent a3f0df5 commit 03daece
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var Monitor = exports.Monitor = function (script, options) {
this.sourceDir = options.sourceDir;
this.cwd = options.cwd || null;
this.env = options.env || {};
this.hideEnv = options.hideEnv || {};

//
// Setup log files and logger for this instance.
Expand Down Expand Up @@ -361,23 +362,25 @@ Monitor.prototype.kill = function (forceStop) {
//
Monitor.prototype._getEnv = function () {
var self = this,
extra = Object.keys(this.env),
merged = {};

if (extra.length === 0) {
return process.env;
}

function addKey (key, source) {
merged[key] = source[key]
}

//
// Mixin the key:value pairs from `process.env` and the custom
// environment variables in `this.env`.
//
Object.keys(process.env).forEach(function (k) { addKey(k, process.env) });
extra.forEach(function (k) { addKey(k, self.env) });
for(var k in process.env) {
if(!self.hideEnv[k]) {
addKey(k, process.env);
}
}

for(var k in this.env) {
addKey(k, this.env);
}

return merged;
};

0 comments on commit 03daece

Please sign in to comment.