Skip to content
Browse files

child process compatibility for node 0.6

  • Loading branch information...
1 parent f3da415 commit c9a42280a7be20b089e2a4ae8c10af37c41cc70e @polotek committed
Showing with 20 additions and 2 deletions.
  1. +15 −0 compat/child_process.js
  2. +2 −0 compat/index.js
  3. +1 −0 package.json
  4. +2 −2 procstreams.js
View
15 compat/child_process.js
@@ -0,0 +1,15 @@
+var semver = require('semver');
+
+exports.fix_child_process = function(cp) {
+ if(semver.lt(process.versions.node, '0.8.0')) {
+ cp.on('exit', function() {
+ var self = this
+ , args = Array.prototype.slice.call(arguments);
+
+ process.nextTick(function() {
+ args.unshift('close');
+ self.emit.apply(self, args);
+ });
+ });
+ }
+}
View
2 compat/index.js
@@ -1 +1,3 @@
require('./buffer')
+
+exports.fix_child_process = require('./child_process').fix_child_process
View
1 package.json
@@ -16,6 +16,7 @@
"inherits": "~1.0"
, "shell-quote": "*"
, "data-collector-stream": "*"
+ , "semver": "*"
}
, "scripts": {
"test": "tests/run_tests.sh"
View
4 procstreams.js
@@ -1,10 +1,9 @@
-require('./compat');
-
var slice = Array.prototype.slice
, EventEmitter = require('events').EventEmitter
, Stream = require('stream')
, spawn = require('child_process').spawn
, inherits = require('inherits')
+ , compat = require('./compat')
, parse = require('shell-quote').parse
, utils = require('./protochains')
, PassThrough = require('./pass-through-stream')
@@ -151,6 +150,7 @@ function procStream(cmd, args, opts, callback) {
proc = procStream.enhanceStream(cmd);
} else {
proc = spawn(cmd, args, opts);
+ compat.fix_child_process(proc);
proc = procStream.enhance(proc);
proc._args = o;

0 comments on commit c9a4228

Please sign in to comment.
Something went wrong with that request. Please try again.