From 65c6051f0f19437c7abac43ade564ed4ec484024 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 17 Nov 2019 19:38:52 +0100 Subject: [PATCH] Add `serialization` option --- index.d.ts | 11 +++++++++++ index.test-d.ts | 1 + readme.md | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/index.d.ts b/index.d.ts index 816c7fd920..afabeec1ef 100644 --- a/index.d.ts +++ b/index.d.ts @@ -135,6 +135,17 @@ declare namespace execa { */ readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[]; + /** + When using the `stdio: 'ipc'` option or `execa.node()`, whether messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) would be serialized: + - `json`: uses `JSON.serialize()` + - `advanced`: uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) + + See more information [here](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). + + @default 'json' + */ + readonly serialization?: 'json' | 'advanced'; + /** Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached). diff --git a/index.test-d.ts b/index.test-d.ts index 7a2e7ea6f6..c9845d12a5 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -115,6 +115,7 @@ execa('unicorns', {stdio: 'inherit'}); execa('unicorns', { stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined] }); +execa('unicorns', {serialization: 'advanced'}); execa('unicorns', {detached: true}); execa('unicorns', {uid: 0}); execa('unicorns', {gid: 0}); diff --git a/readme.md b/readme.md index ee775b667d..aea80fa369 100644 --- a/readme.md +++ b/readme.md @@ -451,6 +451,17 @@ Default: `pipe` Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration. +#### serialization + +Type: `string`
+Default: `json` + +When using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options), whether messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) would be serialized: + - `json`: uses `JSON.serialize()` + - `advanced`: uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) + +See more information [here](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). + #### detached Type: `boolean`