summaryrefslogtreecommitdiff
path: root/lib/child_process.js
diff options
context:
space:
mode:
authorSarat Addepalli <sarat.addepalli@paytm.com>2018-08-20 12:41:40 +0530
committerAnna Henningsen <anna@addaleax.net>2018-08-27 23:40:10 +0200
commit68dff4a67b7222770f90fc5d9bdd884f8db4a24b (patch)
tree2815e9c4d88b4c0e7ab5897c38878217cbeb3ba8 /lib/child_process.js
parent31b3273eaa02ee12188a4c7a64a0d4adfbe22670 (diff)
downloadandroid-node-v8-68dff4a67b7222770f90fc5d9bdd884f8db4a24b.tar.gz
android-node-v8-68dff4a67b7222770f90fc5d9bdd884f8db4a24b.tar.bz2
android-node-v8-68dff4a67b7222770f90fc5d9bdd884f8db4a24b.zip
child_process: allow typed arrays for input
doc: Update child_process docs, stating typed arrays are allowed. error: Update error message for `ERR_INVALID_SYNC_FORK_INPUT` lib: Use isArrayBufferView instead of isUint8Array test: Update test-child-process-spawnsync-input to test for all typed arrays and data view. PR-URL: https://github.com/nodejs/node/pull/22409 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/child_process.js')
-rw-r--r--lib/child_process.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index 6cce1b09e5..1ab4150b01 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -25,7 +25,7 @@ const util = require('util');
const {
deprecate, convertToValidSignal, getSystemErrorName
} = require('internal/util');
-const { isUint8Array } = require('internal/util/types');
+const { isArrayBufferView } = require('internal/util/types');
const debug = util.debuglog('child_process');
const { Buffer } = require('buffer');
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
@@ -572,13 +572,16 @@ function spawnSync(/* file, args, options */) {
var input = options.stdio[i] && options.stdio[i].input;
if (input != null) {
var pipe = options.stdio[i] = util._extend({}, options.stdio[i]);
- if (isUint8Array(input)) {
+ if (isArrayBufferView(input)) {
pipe.input = input;
} else if (typeof input === 'string') {
pipe.input = Buffer.from(input, options.encoding);
} else {
throw new ERR_INVALID_ARG_TYPE(`options.stdio[${i}]`,
- ['Buffer', 'Uint8Array', 'string'],
+ ['Buffer',
+ 'TypedArray',
+ 'DataView',
+ 'string'],
input);
}
}