Skip to content
Myr

Change default value of `serialization` option to `advanced` (#905)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 6642cd2 · Browse files · 5 files+30 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+30 added−2 removed

  • tests:+26 added−0 removed
  • other:+4 added−2 removed

5 files+30 added−2 removed

modified:lib/arguments/options.js+2 added
modified:test/arguments/node.js+20 added
1import {once} from 'node:events';2import {dirname, relative} from 'node:path';3import process from 'node:process';4import {pathToFileURL} from 'node:url';5import test from 'ava';
250 unmodified lines
256257test('Cannot use "shell: true" - execaNode()', testNoShell, execaNode);258test('Cannot use "shell: true" - "node" option', testNoShell, runWithNodeOption);259test('Cannot use "shell: true" - "node" option sync', testNoShell, runWithNodeOptionSync);260261test('The "serialization" option defaults to "advanced"', async t => {262 const subprocess = execa('node', ['ipc-echo.js'], {ipc: true});263 subprocess.send([0n]);264 const [message] = await once(subprocess, 'message');265 t.is(message[0], 0n);266 await subprocess;267});268269test('The "serialization" option can be set to "json"', async t => {270 const subprocess = execa('node', ['ipc-echo.js'], {ipc: true, serialization: 'json'});271 t.throws(() => {272 subprocess.send([0n]);273 }, {message: /serialize a BigInt/});274 subprocess.send(0);275 const [message] = await once(subprocess, 'message');276 t.is(message, 0);277 await subprocess;278});
added:test/fixtures/ipc-echo.js+6 added
modified:index.d.ts+1 added-1 removed
595 unmodified lines
596 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)597598 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)599600 @default 'json'600 @default 'advanced'601 */602 readonly serialization?: IfAsync<IsSync, 'json' | 'advanced'>;603604 /**
794 unmodified lines
modified:readme.md+1 added-1 removed
846 unmodified lines
847848#### serialization849850Type: `string`\851Default: `'json'`851Default: `'advanced'`852853Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#ipc) option:854 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.855 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
216 unmodified lines