mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 07:19:19 +00:00

cp.exec decide to use `_stdout`(_stdout is string) or `Buffer.concat(_stdout)`(_stdout is buffer array) by options.encoding. but std(out|err) encoding can be changed. If encoding is changed to not null, `_stdout` will become string, and `Buffer.concat(_stdout)` will throw TypeError. This patch will fix it, use options.encoding and `std(out|err)._readableState.encoding`. PR-URL: https://github.com/nodejs/node/pull/18976 Fixes: https://github.com/nodejs/node/issues/18969 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
16 lines
330 B
JavaScript
16 lines
330 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { Readable } = require('stream');
|
|
|
|
|
|
{
|
|
const readable = new Readable({ encoding: 'hex' });
|
|
assert.strictEqual(readable._readableState.encoding, 'hex');
|
|
|
|
readable.setEncoding(null);
|
|
|
|
assert.strictEqual(readable._readableState.encoding, 'utf8');
|
|
}
|