| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 383d578 commit 5321c31
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -679,6 +679,10 @@ configuration at startup. | |||
| 679 | 679 | <!-- YAML | |
| 680 | 680 | added: v0.11.12 | |
| 681 | 681 | changes: | |
| 682 | + - version: REPLACEME | ||
| 683 | + pr-url: https://github.com/nodejs/node/pull/22409 | ||
| 684 | + description: The `input` option can now be any `TypedArray` or a | ||
| 685 | + `DataView`. | ||
| 682 | 686 | - version: v8.8.0 | |
| 683 | 687 | pr-url: https://github.com/nodejs/node/pull/15380 | |
| 684 | 688 | description: The `windowsHide` option is supported now. | |
@@ -694,8 +698,9 @@ changes: | |||
| 694 | 698 | * `args` {string[]} List of string arguments. | |
| 695 | 699 | * `options` {Object} | |
| 696 | 700 | * `cwd` {string} Current working directory of the child process. | |
| 697 | - * `input` {string|Buffer|Uint8Array} The value which will be passed as stdin | ||
| 698 | - to the spawned process. Supplying this value will override `stdio[0]`. | ||
| 701 | + * `input` {string|Buffer|TypedArray|DataView} The value which will be passed | ||
| 702 | + as stdin to the spawned process. Supplying this value will override | ||
| 703 | + `stdio[0]`. | ||
| 699 | 704 | * `stdio` {string|Array} Child's stdio configuration. `stderr` by default will | |
| 700 | 705 | be output to the parent process' stderr unless `stdio` is specified. | |
| 701 | 706 | **Default:** `'pipe'`. | |
@@ -741,6 +746,10 @@ arbitrary command execution.** | |||
| 741 | 746 | <!-- YAML | |
| 742 | 747 | added: v0.11.12 | |
| 743 | 748 | changes: | |
| 749 | + - version: REPLACEME | ||
| 750 | + pr-url: https://github.com/nodejs/node/pull/22409 | ||
| 751 | + description: The `input` option can now be any `TypedArray` or a | ||
| 752 | + `DataView`. | ||
| 744 | 753 | - version: v8.8.0 | |
| 745 | 754 | pr-url: https://github.com/nodejs/node/pull/15380 | |
| 746 | 755 | description: The `windowsHide` option is supported now. | |
@@ -752,8 +761,9 @@ changes: | |||
| 752 | 761 | * `command` {string} The command to run. | |
| 753 | 762 | * `options` {Object} | |
| 754 | 763 | * `cwd` {string} Current working directory of the child process. | |
| 755 | - * `input` {string|Buffer|Uint8Array} The value which will be passed as stdin | ||
| 756 | - to the spawned process. Supplying this value will override `stdio[0]`. | ||
| 764 | + * `input` {string|Buffer|TypedArray|DataView} The value which will be passed | ||
| 765 | + as stdin to the spawned process. Supplying this value will override | ||
| 766 | + `stdio[0]`. | ||
| 757 | 767 | * `stdio` {string|Array} Child's stdio configuration. `stderr` by default will | |
| 758 | 768 | be output to the parent process' stderr unless `stdio` is specified. | |
| 759 | 769 | **Default:** `'pipe'`. | |
@@ -795,6 +805,10 @@ metacharacters may be used to trigger arbitrary command execution.** | |||
| 795 | 805 | <!-- YAML | |
| 796 | 806 | added: v0.11.12 | |
| 797 | 807 | changes: | |
| 808 | + - version: REPLACEME | ||
| 809 | + pr-url: https://github.com/nodejs/node/pull/22409 | ||
| 810 | + description: The `input` option can now be any `TypedArray` or a | ||
| 811 | + `DataView`. | ||
| 798 | 812 | - version: v8.8.0 | |
| 799 | 813 | pr-url: https://github.com/nodejs/node/pull/15380 | |
| 800 | 814 | description: The `windowsHide` option is supported now. | |
@@ -813,8 +827,9 @@ changes: | |||
| 813 | 827 | * `args` {string[]} List of string arguments. | |
| 814 | 828 | * `options` {Object} | |
| 815 | 829 | * `cwd` {string} Current working directory of the child process. | |
| 816 | - * `input` {string|Buffer|Uint8Array} The value which will be passed as stdin | ||
| 817 | - to the spawned process. Supplying this value will override `stdio[0]`. | ||
| 830 | + * `input` {string|Buffer|TypedArray|DataView} The value which will be passed | ||
| 831 | + as stdin to the spawned process. Supplying this value will override | ||
| 832 | + `stdio[0]`. | ||
| 818 | 833 | * `argv0` {string} Explicitly set the value of `argv[0]` sent to the child | |
| 819 | 834 | process. This will be set to `command` if not specified. | |
| 820 | 835 | * `stdio` {string|Array} Child's stdio configuration. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1259,8 +1259,8 @@ For example when a function is expected to return a promise. | |||
| 1259 | 1259 | <a id="ERR_INVALID_SYNC_FORK_INPUT"></a> | |
| 1260 | 1260 | ### ERR_INVALID_SYNC_FORK_INPUT | |
| 1261 | 1261 | ||
| 1262 | - A `Buffer`, `Uint8Array` or `string` was provided as stdio input to a | ||
| 1263 | - synchronous fork. See the documentation for the [`child_process`][] module | ||
| 1262 | + A `Buffer`, `TypedArray`, `DataView` or `string` was provided as stdio input to | ||
| 1263 | + an asynchronous fork. See the documentation for the [`child_process`][] module | ||
| 1264 | 1264 | for more information. | |
| 1265 | 1265 | ||
| 1266 | 1266 | <a id="ERR_INVALID_THIS"></a> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ const util = require('util'); | |||
| 25 | 25 | const { | |
| 26 | 26 | deprecate, convertToValidSignal, getSystemErrorName | |
| 27 | 27 | } = require('internal/util'); | |
| 28 | - const { isUint8Array } = require('internal/util/types'); | ||
| 28 | + const { isArrayBufferView } = require('internal/util/types'); | ||
| 29 | 29 | const debug = util.debuglog('child_process'); | |
| 30 | 30 | const { Buffer } = require('buffer'); | |
| 31 | 31 | const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); | |
@@ -570,13 +570,16 @@ function spawnSync(/* file, args, options */) { | |||
| 570 | 570 | var input = options.stdio[i] && options.stdio[i].input; | |
| 571 | 571 | if (input != null) { | |
| 572 | 572 | var pipe = options.stdio[i] = util._extend({}, options.stdio[i]); | |
| 573 | - if (isUint8Array(input)) { | ||
| 573 | + if (isArrayBufferView(input)) { | ||
| 574 | 574 | pipe.input = input; | |
| 575 | 575 | } else if (typeof input === 'string') { | |
| 576 | 576 | pipe.input = Buffer.from(input, options.encoding); | |
| 577 | 577 | } else { | |
| 578 | 578 | throw new ERR_INVALID_ARG_TYPE(`options.stdio[${i}]`, | |
| 579 | - ['Buffer', 'Uint8Array', 'string'], | ||
| 579 | + ['Buffer', | ||
| 580 | + 'TypedArray', | ||
| 581 | + 'DataView', | ||
| 582 | + 'string'], | ||
| 580 | 583 | input); | |
| 581 | 584 | } | |
| 582 | 585 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ const { UDP } = process.binding('udp_wrap'); | |||
| 30 | 30 | const SocketList = require('internal/socket_list'); | |
| 31 | 31 | const { owner_symbol } = require('internal/async_hooks').symbols; | |
| 32 | 32 | const { convertToValidSignal } = require('internal/util'); | |
| 33 | - const { isUint8Array } = require('internal/util/types'); | ||
| 33 | + const { isArrayBufferView } = require('internal/util/types'); | ||
| 34 | 34 | const spawn_sync = process.binding('spawn_sync'); | |
| 35 | 35 | const { HTTPParser } = process.binding('http_parser'); | |
| 36 | 36 | const { freeParser } = require('_http_common'); | |
@@ -926,7 +926,7 @@ function _validateStdio(stdio, sync) { | |||
| 926 | 926 | wrapType: getHandleWrapType(handle), | |
| 927 | 927 | handle: handle | |
| 928 | 928 | }); | |
| 929 | - } else if (isUint8Array(stdio) || typeof stdio === 'string') { | ||
| 929 | + } else if (isArrayBufferView(stdio) || typeof stdio === 'string') { | ||
| 930 | 930 | if (!sync) { | |
| 931 | 931 | cleanup(); | |
| 932 | 932 | throw new ERR_INVALID_SYNC_FORK_INPUT(util.inspect(stdio)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -719,7 +719,8 @@ E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { | |||
| 719 | 719 | ` function but got ${type}.`; | |
| 720 | 720 | }, TypeError); | |
| 721 | 721 | E('ERR_INVALID_SYNC_FORK_INPUT', | |
| 722 | - 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s', | ||
| 722 | + 'Asynchronous forks do not support ' + | ||
| 723 | + 'Buffer, TypedArray, DataView or string input: %s', | ||
| 723 | 724 | TypeError); | |
| 724 | 725 | E('ERR_INVALID_THIS', 'Value of "this" must be of type %s', TypeError); | |
| 725 | 726 | E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,16 +100,21 @@ checkSpawnSyncRet(ret); | |||
| 100 | 100 | assert.deepStrictEqual(ret.stdout, options.input); | |
| 101 | 101 | assert.deepStrictEqual(ret.stderr, Buffer.from('')); | |
| 102 | 102 | ||
| 103 | - options = { | ||
| 104 | - input: Uint8Array.from(Buffer.from('hello world')) | ||
| 105 | - }; | ||
| 103 | + // common.getArrayBufferViews expects a buffer | ||
| 104 | + // with length an multiple of 8 | ||
| 105 | + const msgBuf = Buffer.from('hello world'.repeat(8)); | ||
| 106 | + for (const arrayBufferView of common.getArrayBufferViews(msgBuf)) { | ||
| 107 | + options = { | ||
| 108 | + input: arrayBufferView | ||
| 109 | + }; | ||
| 106 | 110 | ||
| 107 | - ret = spawnSync('cat', [], options); | ||
| 111 | + ret = spawnSync('cat', [], options); | ||
| 108 | 112 | ||
| 109 | - checkSpawnSyncRet(ret); | ||
| 110 | - // Wrap options.input because Uint8Array and Buffer have different prototypes. | ||
| 111 | - assert.deepStrictEqual(ret.stdout, Buffer.from(options.input)); | ||
| 112 | - assert.deepStrictEqual(ret.stderr, Buffer.from('')); | ||
| 113 | + checkSpawnSyncRet(ret); | ||
| 114 | + | ||
| 115 | + assert.deepStrictEqual(ret.stdout, msgBuf); | ||
| 116 | + assert.deepStrictEqual(ret.stderr, Buffer.from('')); | ||
| 117 | + } | ||
| 113 | 118 | ||
| 114 | 119 | verifyBufOutput(spawnSync(process.execPath, args)); | |
| 115 | 120 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments