Skip to content

Commit

Permalink
[dist] Update for JSHint
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Oct 9, 2011
1 parent 4e27e3d commit f7575f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
33 changes: 18 additions & 15 deletions lib/forever/monitor.js
Expand Up @@ -59,7 +59,7 @@ var Monitor = exports.Monitor = function (script, options) {
this.env = options.env || {}; this.env = options.env || {};
this.hideEnv = options.hideEnv || []; this.hideEnv = options.hideEnv || [];
this._hideEnv = {}; this._hideEnv = {};

// //
// Create a simple mapping of `this.hideEnv` to an easily indexable // Create a simple mapping of `this.hideEnv` to an easily indexable
// object // object
Expand Down Expand Up @@ -149,7 +149,7 @@ Monitor.prototype.start = function (restart) {
}); });
return this; return this;
} }

child = this.trySpawn(); child = this.trySpawn();
if (!child) { if (!child) {
process.nextTick(function () { process.nextTick(function () {
Expand Down Expand Up @@ -374,14 +374,17 @@ Monitor.prototype.kill = function (forceStop) {
if (forceStop) { if (forceStop) {
this.forceStop = true; this.forceStop = true;
} }

if (this.killTree) { if (this.killTree) {
psTree(this.child.pid, function (err, children) { psTree(this.child.pid, function (err, children) {
var pids = children.map(function (p) { return p.PID }) var pids = children.map(function (p) {
pids.shift(self.child.pid) return p.PID;
});

pids.shift(self.child.pid);
spawn('kill', ['-9'].concat(pids)).on('exit', function () { spawn('kill', ['-9'].concat(pids)).on('exit', function () {
self.emit('stop', self.childData); self.emit('stop', self.childData);
}) });
}); });
} }
else { else {
Expand All @@ -406,12 +409,12 @@ Monitor.prototype.watch = function () {
forever.log.warn('Could not read .foreverignore file.'); forever.log.warn('Could not read .foreverignore file.');
return forever.log.silly(err.message); return forever.log.silly(err.message);
} }

Array.prototype.push.apply(self.watchIgnorePatterns, data.split('\n')); Array.prototype.push.apply(self.watchIgnorePatterns, data.split('\n'));
}); });


watch.watchTree(this.watchDirectory, function (f, curr, prev) { watch.watchTree(this.watchDirectory, function (f, curr, prev) {
if (!(curr == null && prev == null && typeof f == 'object')) { if (!(curr === null && prev === null && typeof f === 'object')) {
// //
// `curr` == null && `prev` == null && typeof f == "object" when watch // `curr` == null && `prev` == null && typeof f == "object" when watch
// finishes walking the tree to add listeners. We don't need to know // finishes walking the tree to add listeners. We don't need to know
Expand All @@ -422,7 +425,7 @@ Monitor.prototype.watch = function () {
self.info('restaring script because ' + f + ' changed'); self.info('restaring script because ' + f + ' changed');
self.restart(); self.restart();
} }
}; }
}); });
}; };


Expand All @@ -433,16 +436,16 @@ Monitor.prototype.watch = function () {
// is pretty messed up). // is pretty messed up).
// //
Monitor.prototype._watchFilter = function (fileName) { Monitor.prototype._watchFilter = function (fileName) {
if (this.watchIgnoreDotFiles && path.basename(fileName)[0] == '.') { if (this.watchIgnoreDotFiles && path.basename(fileName)[0] === '.') {
return false; return false;
} }

for (var key in this.watchIgnorePatterns) { for (var key in this.watchIgnorePatterns) {
if (minimatch(fileName, this.watchIgnorePatterns[key], { matchBase: this.watchDirectory })) { if (minimatch(fileName, this.watchIgnorePatterns[key], { matchBase: this.watchDirectory })) {
return false; return false;
} }
} }

return true; return true;
}; };


Expand All @@ -458,7 +461,7 @@ Monitor.prototype._getEnv = function () {
function addKey(key, source) { function addKey(key, source) {
merged[key] = source[key]; merged[key] = source[key];
} }

// //
// Mixin the key:value pairs from `process.env` and the custom // Mixin the key:value pairs from `process.env` and the custom
// environment variables in `this.env`. // environment variables in `this.env`.
Expand All @@ -468,7 +471,7 @@ Monitor.prototype._getEnv = function () {
addKey(key, process.env); addKey(key, process.env);
} }
}); });

Object.keys(this.env).forEach(function (key) { Object.keys(this.env).forEach(function (key) {
addKey(key, self.env); addKey(key, self.env);
}); });
Expand Down
2 changes: 1 addition & 1 deletion lib/forever/service/index.js
Expand Up @@ -11,5 +11,5 @@ fs.readdirSync(path.join(__dirname, 'adapters')).forEach(function (file) {
file = file.replace(/\.js/, ''); file = file.replace(/\.js/, '');
service.adapters.__defineGetter__(file, function () { service.adapters.__defineGetter__(file, function () {
return require(__dirname + '/adapters/' + file); return require(__dirname + '/adapters/' + file);
}) });
}); });
2 changes: 1 addition & 1 deletion lib/forever/service/service.js
Expand Up @@ -10,7 +10,7 @@ var fs = require('fs'),
// options // options
// directories {log, pid, conf, run, local} // directories {log, pid, conf, run, local}
var Service = module.exports = function Service(options) { var Service = module.exports = function Service(options) {
EventEmitter2.call(this); events.EventEmitter.call(this);
options = options || {}; options = options || {};


var self = this, var self = this,
Expand Down

0 comments on commit f7575f9

Please sign in to comment.