From fe2d19361332f175c2a198a248a07152fb646fc9 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 17 Nov 2019 19:38:52 +0100 Subject: [PATCH 1/7] 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..b4dfc0b26b 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()`, how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are 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..2f0653cc38 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), how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are 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` From afb47951d9a9f550a0491e768d6c6c804c154332 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 24 Nov 2019 15:00:14 +0100 Subject: [PATCH 2/7] Update readme.md Co-Authored-By: Sindre Sorhus --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2f0653cc38..1ea2a68adf 100644 --- a/readme.md +++ b/readme.md @@ -454,7 +454,7 @@ Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_ #### serialization Type: `string`
-Default: `json` +Default: `'json'` When using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options), how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: - `json`: uses `JSON.serialize()` From 405299cb66bcb5a5dab508746570899974cb3142 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 24 Nov 2019 15:00:29 +0100 Subject: [PATCH 3/7] Update index.d.ts Co-Authored-By: Sindre Sorhus --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b4dfc0b26b..93664b6132 100644 --- a/index.d.ts +++ b/index.d.ts @@ -140,7 +140,7 @@ declare namespace execa { - `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). + [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). @default 'json' */ From f7e514ecdbb2797d7d470dd953558eb841017bf1 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 24 Nov 2019 15:00:46 +0100 Subject: [PATCH 4/7] Update readme.md Co-Authored-By: Sindre Sorhus --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1ea2a68adf..d8d459b8bd 100644 --- a/readme.md +++ b/readme.md @@ -457,7 +457,7 @@ Type: `string`
Default: `'json'` When using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options), how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: - - `json`: uses `JSON.serialize()` + - `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). From 6cd91fc1946c8c5bede7daf285680b3775dbb640 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 24 Nov 2019 15:00:57 +0100 Subject: [PATCH 5/7] Update index.d.ts Co-Authored-By: Sindre Sorhus --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 93664b6132..a6c9caf7b7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -138,7 +138,7 @@ declare namespace execa { /** When using the `stdio: 'ipc'` option or `execa.node()`, how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: - `json`: uses `JSON.serialize()` - - `advanced`: uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) + - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). From 842a8d9c757460aac351ac6dc7abe9368e17233e Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 24 Nov 2019 15:01:03 +0100 Subject: [PATCH 6/7] Update index.d.ts Co-Authored-By: Sindre Sorhus --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index a6c9caf7b7..cb4a5f4721 100644 --- a/index.d.ts +++ b/index.d.ts @@ -137,7 +137,7 @@ declare namespace execa { /** When using the `stdio: 'ipc'` option or `execa.node()`, how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: - - `json`: uses `JSON.serialize()` + - `json`: Uses `JSON.stringify()` and `JSON.parse()`. - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). From 6c7f4938d5712e39d89a2049219ee51821993517 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 17 Nov 2019 21:15:48 +0100 Subject: [PATCH 7/7] Fix documentation --- index.d.ts | 6 ++++-- readme.md | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index cb4a5f4721..83a995301e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -136,11 +136,13 @@ declare namespace execa { readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[]; /** - When using the `stdio: 'ipc'` option or `execa.node()`, how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: + Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execa.node()`: - `json`: Uses `JSON.stringify()` and `JSON.parse()`. - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) - [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization). + Requires Node.js `13.2.0` or later. + + [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization) @default 'json' */ diff --git a/readme.md b/readme.md index d8d459b8bd..38397ce175 100644 --- a/readme.md +++ b/readme.md @@ -456,11 +456,13 @@ Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_ Type: `string`
Default: `'json'` -When using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options), how messages passed to [`childProcess.send()`](https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback) are serialized: - - `json`: uses `JSON.serialize()` - - `advanced`: uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) +Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options): + - `json`: Uses `JSON.stringify()` and `JSON.parse()`. + - `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). +Requires Node.js `13.2.0` or later. + +[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization) #### detached