Skip to content
Myr

subprocess.test-d.ts

This file

Path

test-d/subprocess/subprocess.test-d.ts

58 lines · 2.5 KiB · TypeScript

Last changed by

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 1why, one step back
1import type {ChildProcess} from 'node:child_process';

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 2why, one step back
2import {expectTypeOf, expectError} from 'nz';

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 3why, one step back
3import {execa, type Result, type Subprocess} from '../../index.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–5why, one step back
4
5const subprocess = execa('unicorns');

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 6–7why, one step back
6expectTypeOf(subprocess).toBeAssignableTo<Subprocess>();
7expectTypeOf(await subprocess).toBe<Result<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 8why, one step back
8

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 9–10why, one step back
9expectTypeOf(subprocess.pid).toBe<number | undefined>();
10expectTypeOf(subprocess.nodeChildProcess).toBe<ChildProcess>();

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 11–16why, one step back
11subprocess.nodeChildProcess.on('exit', () => undefined);
12subprocess.nodeChildProcess.once('exit', () => undefined);13subprocess.nodeChildProcess.ref();14subprocess.nodeChildProcess.unref();15subprocess.nodeChildProcess.send('message');16subprocess.nodeChildProcess.disconnect();

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 17–22why, one step back
17expectTypeOf(subprocess.nodeChildProcess.connected).toBe<boolean>();
18expectTypeOf(subprocess.nodeChildProcess.exitCode).toBe<number | null>();19expectTypeOf(subprocess.nodeChildProcess.signalCode).toBe<NodeJS.Signals | null>();20expectTypeOf(subprocess.nodeChildProcess.killed).toBe<boolean>();21expectTypeOf(subprocess.nodeChildProcess.spawnargs).toBe<string[]>();22expectTypeOf(subprocess.nodeChildProcess.spawnfile).toBe<string>();

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 23–35why, one step back
23expectError(subprocess.on('exit', () => undefined));
24expectError(subprocess.once('exit', () => undefined));25expectError(subprocess.ref());26expectError(subprocess.unref());27expectError(subprocess.send('message'));28expectError(subprocess.disconnect());29expectError(subprocess.connected);30expectError(subprocess.channel);31expectError(subprocess.exitCode);32expectError(subprocess.signalCode);33expectError(subprocess.killed);34expectError(subprocess.spawnargs);35expectError(subprocess.spawnfile);

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 36why, one step back
36

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 37why, one step back
37expectTypeOf(subprocess.kill()).toBe<boolean>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 38–44why, one step back
38subprocess.kill('SIGKILL');
39subprocess.kill(undefined);40subprocess.kill(new Error('test'));41subprocess.kill('SIGKILL', new Error('test'));42subprocess.kill(undefined, new Error('test'));43expectError(subprocess.kill(null));44expectError(subprocess.kill(0n));

Improve validation and typing of signals (#1025)ehmickybefore adoption7213287

lines 45–50why, one step back
45expectError(subprocess.kill('Sigkill'));
46expectError(subprocess.kill('sigkill'));47expectError(subprocess.kill('SIGOTHER'));48expectError(subprocess.kill('SIGEMT'));49expectError(subprocess.kill('SIGCLD'));50expectError(subprocess.kill('SIGRT1'));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 51–57why, one step back
51expectError(subprocess.kill([new Error('test')]));
52expectError(subprocess.kill({message: 'test'}));53expectError(subprocess.kill(undefined, {}));54expectError(subprocess.kill('SIGKILL', {}));55expectError(subprocess.kill(null, new Error('test')));5657const ipcSubprocess = execa('unicorns', {ipc: true});

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 58why, one step back
58expectTypeOf(ipcSubprocess).toBeAssignableTo<Subprocess>();