Skip to content

Commit d2ee224

Browse files
committed
Use cross-spawn types instead of raw types from Node
Cleans up some of the fallout from #11684 which simplified some code but removed some type safety.
1 parent 9759b8e commit d2ee224

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

packages/create-docusaurus/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"tslib": "^2.6.0"
3232
},
3333
"devDependencies": {
34+
"@types/cross-spawn": "^6.0.6",
3435
"@types/supports-color": "^10.0.0"
3536
},
3637
"engines": {

packages/create-docusaurus/src/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
// @ts-expect-error: no types, but same as spawn()
9-
import CrossSpawn from 'cross-spawn';
10-
import type {spawn, SpawnOptions} from 'node:child_process';
8+
import crossSpawn from 'cross-spawn';
9+
10+
// This is the same as node's child_process.SpawnOptions type, but extract from
11+
// cross-spawn directly to ensure direct compatibility.
12+
type SpawnOptions = NonNullable<Parameters<typeof crossSpawn>[2]>;
1113

1214
// We use cross-spawn instead of spawn because of Windows compatibility issues.
1315
// For example, "yarn" doesn't work on Windows, it requires "yarn.cmd"
1416
// Tools like execa() use cross-spawn under the hood, and "resolve" the command
15-
const crossSpawn: typeof spawn = CrossSpawn;
1617

1718
/**
1819
* Run a command, similar to execa(cmd,args) but simpler

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,6 +4617,13 @@
46174617
dependencies:
46184618
"@types/node" "*"
46194619

4620+
"@types/cross-spawn@^6.0.6":
4621+
version "6.0.6"
4622+
resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.6.tgz#0163d0b79a6f85409e0decb8dcca17147f81fd22"
4623+
integrity sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA==
4624+
dependencies:
4625+
"@types/node" "*"
4626+
46204627
"@types/d3-array@*":
46214628
version "3.2.1"
46224629
resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-3.2.1.tgz#1f6658e3d2006c4fceac53fde464166859f8b8c5"

0 commit comments

Comments
 (0)