Skip to content

Commit

Permalink
Check for existence of process object
Browse files Browse the repository at this point in the history
  • Loading branch information
th0r committed Jun 20, 2019
1 parent b3cf9b1 commit fd4dda7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
state.pipesCount += 1;
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);

var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
var doEnd = (!pipeOpts || pipeOpts.end !== false) && !isStdStream(dest);

var endFn = doEnd ? onend : unpipe;
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
Expand Down Expand Up @@ -1016,4 +1016,12 @@ function indexOf(xs, x) {
if (xs[i] === x) return i;
}
return -1;
}
}

function isStdStream(stream) {
if (typeof process === 'undefined') {
return false;
} else {
return (stream === process.stdout || stream === process.stdin);
}
}
4 changes: 2 additions & 2 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function CorkedRequest(state) {
/* </replacement> */

/*<replacement>*/
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
var asyncWrite = (typeof process !== 'undefined') && !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
/*</replacement>*/

/*<replacement>*/
Expand Down Expand Up @@ -684,4 +684,4 @@ Writable.prototype._undestroy = destroyImpl.undestroy;
Writable.prototype._destroy = function (err, cb) {
this.end();
cb(err);
};
};

0 comments on commit fd4dda7

Please sign in to comment.