Skip to content

Commit 4d000a7

Browse files
committed
refactor(spawn): improve ChildProcess type definition
- Rename ChildProcessType to ChildProcess for clarity - Make ChildProcess interface extend EventEmitter - Update type references throughout spawn module This ensures accurate type representation of spawned child processes and aligns naming with Node.js conventions.
1 parent 1882c46 commit 4d000a7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/spawn.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { getOwn, hasOwn } from './objects'
3838
import { getDefaultSpinner } from './spinner'
3939
import { stripAnsi } from './strings'
4040

41+
import type { EventEmitter } from 'node:events'
42+
4143
const abortSignal = getAbortSignal()
4244
const spinner = getDefaultSpinner()
4345

@@ -98,7 +100,7 @@ export type PromiseSpawnOptions = {
98100
* This is a Promise that resolves with process exit information and output,
99101
* with additional properties for accessing the running process and stdin stream.
100102
*
101-
* @property {ChildProcessType} process - The running child process instance
103+
* @property {ChildProcess} process - The running child process instance
102104
* @property {WritableStreamType | null} stdin - Writable stream for process stdin, or `null` if not piped
103105
*
104106
* @example
@@ -115,7 +117,7 @@ export type PromiseSpawnResult = Promise<{
115117
stdout: string | Buffer
116118
stderr: string | Buffer
117119
}> & {
118-
process: ChildProcessType
120+
process: ChildProcess
119121
stdin: WritableStreamType | null
120122
}
121123

@@ -350,7 +352,7 @@ interface NodeSpawnOptions {
350352

351353
// Duplicated from Node.js child_process.ChildProcess
352354
// This represents a spawned child process
353-
interface ChildProcessType {
355+
interface ChildProcess extends EventEmitter {
354356
stdin: NodeJS.WritableStream | null
355357
stdout: NodeJS.ReadableStream | null
356358
stderr: NodeJS.ReadableStream | null

0 commit comments

Comments
 (0)