Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[minor dist] Added LICENSE. Refactor forever.js to be more DRY

  • Loading branch information...
commit f9163595396904704be2500b966072532e1835b8 1 parent 9243dee
Charlie Robbins indexzero authored
Showing with 30 additions and 14 deletions.
  1. +19 −0 LICENSE
  2. +11 −14 lib/forever.js
19 LICENSE
View
@@ -0,0 +1,19 @@
+Copyright (c) 2009 Charlie Robbins
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
25 lib/forever.js
View
@@ -42,29 +42,26 @@ Forever.prototype.run = function () {
var self = this, child = spawn('node', this.options.options);
this.child = child;
- // Hook all stream data
- // And process it
- function hookStream(streamType) {
- child[streamType].on('data', function (data) {
+ // Hook all stream data and process it
+ function listenTo (stream) {
+ child[stream].on('data', function (data) {
// If we haven't been silenced, write to the process stdout stream
if (!self.options.silent) {
- process[streamType].write(data);
+ process.stdout.write(data);
}
- // If we have been given an output file for stdout, write to it
- if (self.options[streamType]) {
- self[streamType].write(data);
+ // If we have been given an output file for the stream, write to it
+ if (self.options[stream]) {
+ self[stream].write(data);
}
- self.emit(streamType, null, data);
+ self.emit(stream, null, data);
});
-
- // Chaining
- return hookStream;
}
- // Hook stdout and stderr
- hookStream('stdout')('stderr');
+ // Listen to stdout and stderr
+ listenTo('stdout');
+ listenTo('stderr');
child.on('exit', function (code) {
self.times++;
Please sign in to comment.
Something went wrong with that request. Please try again.