From 33647643e666f5b743301ef38acfdd4df9f5990b Mon Sep 17 00:00:00 2001 From: Anil Loutombam Date: Sun, 9 Aug 2026 12:05:16 +0530 Subject: [PATCH 1/3] feat: add cross-spawn replacement --- manifests/preferred.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manifests/preferred.json b/manifests/preferred.json index 80a7525d..41c20268 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -196,6 +196,11 @@ "replacements": ["fetch", "ofetch", "ky"], "url": {"type": "e18e", "id": "fetch"} }, + "cross-spawn": { + "type": "module", + "moduleName": "cross-spawn", + "replacements": ["tinyexec"] + }, "crypto-js": { "type": "module", "moduleName": "crypto-js", From 754cf3395e6def965e6d8d31e868138dd2a52c79 Mon Sep 17 00:00:00 2001 From: Anil Loutombam Date: Sun, 9 Aug 2026 15:25:30 +0530 Subject: [PATCH 2/3] docs: add cross-spawn migration guidance --- docs/modules/cross-spawn.md | 33 +++++++++++++++++++++++++++++++++ manifests/preferred.json | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 docs/modules/cross-spawn.md diff --git a/docs/modules/cross-spawn.md b/docs/modules/cross-spawn.md new file mode 100644 index 00000000..9cc36fc5 --- /dev/null +++ b/docs/modules/cross-spawn.md @@ -0,0 +1,33 @@ +--- +description: Modern alternatives to the cross-spawn package for spawning child processes +--- + +# Replacements for `cross-spawn` + +## `tinyexec` + +[`tinyexec`](https://github.com/tinylibs/tinyexec) is a minimal, dependency-free process execution library. + +`cross-spawn` follows the Node.js `spawn` API and returns a `ChildProcess`. In comparison, `tinyexec` returns an awaitable result containing the process output and exit code. + +Example: + +```ts +import spawn from 'cross-spawn' // [!code --] +import { x } from 'tinyexec' // [!code ++] + +const child = spawn('npm', ['list', '-g']) // [!code --] +const { stdout, exitCode } = await x('npm', ['list', '-g']) // [!code ++] + +child.stdout?.on('data', (output) => console.log(output.toString())) // [!code --] +console.log(stdout, exitCode) // [!code ++] +``` + +If your application only targets Linux, or otherwise does not require the Windows compatibility handling provided by `cross-spawn`, you may not need another package. You can use the built-in `node:child_process` module directly: + +```ts +import spawn from 'cross-spawn' // [!code --] +import { spawn } from 'node:child_process' // [!code ++] + +const child = spawn('npm', ['list', '-g']) +``` diff --git a/manifests/preferred.json b/manifests/preferred.json index 41c20268..f3a0b56e 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -199,7 +199,8 @@ "cross-spawn": { "type": "module", "moduleName": "cross-spawn", - "replacements": ["tinyexec"] + "replacements": ["tinyexec"], + "url": {"type": "e18e", "id": "cross-spawn"} }, "crypto-js": { "type": "module", From 5008adde4741b71de14e42a0829fed6fb98cb550 Mon Sep 17 00:00:00 2001 From: Anil Loutombam Date: Sun, 9 Aug 2026 16:17:42 +0530 Subject: [PATCH 3/3] docs: refine cross-spawn migration guidance --- docs/modules/cross-spawn.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/modules/cross-spawn.md b/docs/modules/cross-spawn.md index 9cc36fc5..0f3ebb82 100644 --- a/docs/modules/cross-spawn.md +++ b/docs/modules/cross-spawn.md @@ -4,6 +4,9 @@ description: Modern alternatives to the cross-spawn package for spawning child p # Replacements for `cross-spawn` +> [!NOTE] +> If your application does not need to support Windows, you can likely drop `cross-spawn` entirely as it solely exists to provide Windows spawn compatibility. You can use the built-in `node:child_process` in that case. + ## `tinyexec` [`tinyexec`](https://github.com/tinylibs/tinyexec) is a minimal, dependency-free process execution library. @@ -22,12 +25,3 @@ const { stdout, exitCode } = await x('npm', ['list', '-g']) // [!code ++] child.stdout?.on('data', (output) => console.log(output.toString())) // [!code --] console.log(stdout, exitCode) // [!code ++] ``` - -If your application only targets Linux, or otherwise does not require the Windows compatibility handling provided by `cross-spawn`, you may not need another package. You can use the built-in `node:child_process` module directly: - -```ts -import spawn from 'cross-spawn' // [!code --] -import { spawn } from 'node:child_process' // [!code ++] - -const child = spawn('npm', ['list', '-g']) -```