Stop closing STDOUT/STDERR in lib/streams.ts (#5419)

Fixes #5403 for Node versions prior to v10.12.0.
This commit is contained in:
Kirk Scheibelhut 2019-04-07 00:34:06 -07:00 committed by Guangcong Luo
parent a8b9bed753
commit 15fe4d2ff1

View File

@ -366,11 +366,14 @@ export class WriteStream {
this.drainListeners.push(resolve);
});
};
options.end = function () {
return new Promise(resolve => {
this.nodeWritableStream!.end(() => resolve());
});
};
// Prior to Node v10.12.0, attempting to close STDOUT or STDERR will throw
if (nodeStream !== process.stdout && nodeStream !== process.stderr) {
options.end = function () {
return new Promise(resolve => {
this.nodeWritableStream!.end(() => resolve());
});
};
}
}
if (options.write) this._write = options.write;
@ -671,11 +674,14 @@ export class ObjectWriteStream<T> {
}
};
options.end = function () {
return new Promise(resolve => {
this.nodeWritableStream!.end(() => resolve());
});
};
// Prior to Node v10.12.0, attempting to close STDOUT or STDERR will throw
if (nodeStream !== process.stdout && nodeStream !== process.stderr) {
options.end = function () {
return new Promise(resolve => {
this.nodeWritableStream!.end(() => resolve());
});
};
}
}
if (options.write) this._write = options.write;