diff options
author | ZYSzys <zyszys98@gmail.com> | 2019-07-05 15:54:34 +0800 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-07-20 11:10:28 +0200 |
commit | 00b2200e035ace6c034b8b646024ca37733a7ac4 (patch) | |
tree | b450f80e604b79a0f15c1dfbfbd1e634207acf20 /lib | |
parent | 499969db9e13eb2d43fac9e82ea98314038968ab (diff) | |
download | android-node-v8-00b2200e035ace6c034b8b646024ca37733a7ac4.tar.gz android-node-v8-00b2200e035ace6c034b8b646024ca37733a7ac4.tar.bz2 android-node-v8-00b2200e035ace6c034b8b646024ca37733a7ac4.zip |
stream: use readableEncoding public api for child_process
PR-URL: https://github.com/nodejs/node/pull/28548
Refs: https://github.com/nodejs/node/issues/445
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_readable.js | 7 | ||||
-rw-r--r-- | lib/child_process.js | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index d6db718875..76077a117a 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -1105,6 +1105,13 @@ Object.defineProperty(Readable.prototype, 'readableObjectMode', { } }); +Object.defineProperty(Readable.prototype, 'readableEncoding', { + enumerable: false, + get() { + return this._readableState ? this._readableState.encoding : null; + } +}); + // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. // This function is designed to be inlinable, so please take care when making diff --git a/lib/child_process.js b/lib/child_process.js index 0d3785f0d5..43257e53df 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -266,8 +266,7 @@ function execFile(file /* , args, options, callback */) { if (encoding || ( child.stdout && - child.stdout._readableState && - child.stdout._readableState.encoding + child.stdout.readableEncoding )) { stdout = _stdout.join(''); } else { @@ -276,8 +275,7 @@ function execFile(file /* , args, options, callback */) { if (encoding || ( child.stderr && - child.stderr._readableState && - child.stderr._readableState.encoding + child.stderr.readableEncoding )) { stderr = _stderr.join(''); } else { @@ -344,7 +342,7 @@ function execFile(file /* , args, options, callback */) { child.stdout.setEncoding(encoding); child.stdout.on('data', function onChildStdout(chunk) { - const encoding = child.stdout._readableState.encoding; + const encoding = child.stdout.readableEncoding; const length = encoding ? Buffer.byteLength(chunk, encoding) : chunk.length; @@ -367,7 +365,7 @@ function execFile(file /* , args, options, callback */) { child.stderr.setEncoding(encoding); child.stderr.on('data', function onChildStderr(chunk) { - const encoding = child.stderr._readableState.encoding; + const encoding = child.stderr.readableEncoding; const length = encoding ? Buffer.byteLength(chunk, encoding) : chunk.length; |