@@ -2,59 +2,39 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
22import * as Rx from 'rxjs' ;
33import { EventEmitter , Writable } from 'stream' ;
44
5- /**
6- * Identifier for a command; if string, it's the command's name, if number, it's the index.
7- */
5+ /** Identifier for a command; if string, it's the command's name, if number, it's the index.*/
86export type CommandIdentifier = string | number ;
97
108export interface CommandInfo {
11- /**
12- * Command's name.
13- */
9+ /** Command's name. */
1410 name : string ;
1511
16- /**
17- * Which command line the command has.
18- */
12+ /** Which command line the command has. */
1913 command : string ;
2014
21- /**
22- * Which environment variables should the spawned process have.
23- */
15+ /** Which environment variables should the spawned process have.*/
2416 env ?: Record < string , unknown > ;
2517
26- /**
27- * The current working directory of the process when spawned.
28- */
18+ /** The current working directory of the process when spawned.*/
2919 cwd ?: string ;
3020
31- /**
32- * Color to use on prefix of the command.
33- */
21+ /** Color to use on prefix of the command.*/
3422 prefixColor ?: string ;
3523
36- /**
37- * Output command in raw format.
38- */
24+ /** Output command in raw format.*/
3925 raw ?: boolean ;
4026}
4127
4228export interface CloseEvent {
4329 command : CommandInfo ;
4430
45- /**
46- * The command's index among all commands ran.
47- */
31+ /** The command's index among all commands ran.*/
4832 index : number ;
4933
50- /**
51- * Whether the command exited because it was killed.
52- */
34+ /** Whether the command exited because it was killed.*/
5335 killed : boolean ;
5436
55- /**
56- * The exit code or signal for the command.
57- */
37+ /** The exit code or signal for the command.*/
5838 exitCode : string | number ;
5939 timings : {
6040 startDate : Date ;
@@ -68,20 +48,14 @@ export interface TimerEvent {
6848 endDate ?: Date ;
6949}
7050
71- /**
72- * Subtype of NodeJS's child_process including only what's actually needed for a command to work.
73- */
51+ /** Subtype of NodeJS's child_process including only what's actually needed for a command to work. */
7452export type ChildProcess = EventEmitter &
7553 Pick < BaseChildProcess , 'pid' | 'stdin' | 'stdout' | 'stderr' > ;
7654
77- /**
78- * Interface for a function that must kill the process with `pid`, optionally sending `signal` to it.
79- */
55+ /** Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. */
8056export type KillProcess = ( pid : number , signal ?: string ) => void ;
8157
82- /**
83- * Interface for a function that spawns a command and returns its child process instance.
84- */
58+ /** Interface for a function that spawns a command and returns its child process instance. */
8559export type SpawnCommand = ( command : string , options : SpawnOptions ) => ChildProcess ;
8660
8761export class Command implements CommandInfo {
@@ -139,9 +113,7 @@ export class Command implements CommandInfo {
139113 this . spawnOpts = spawnOpts ;
140114 }
141115
142- /**
143- * Starts this command, piping output, error and close events onto the corresponding observables.
144- */
116+ /** Starts this command, piping output, error and close events onto the corresponding observables. */
145117 start ( ) {
146118 const child = this . spawn ( this . command , this . spawnOpts ) ;
147119 this . process = child ;
@@ -190,9 +162,7 @@ export class Command implements CommandInfo {
190162 this . stdin = child . stdin || undefined ;
191163 }
192164
193- /**
194- * Kills this command, optionally specifying a signal to send to it.
195- */
165+ /** Kills this command, optionally specifying a signal to send to it. */
196166 kill ( code ?: string ) {
197167 if ( Command . canKill ( this ) ) {
198168 this . killed = true ;
@@ -210,9 +180,7 @@ export class Command implements CommandInfo {
210180 }
211181}
212182
213- /**
214- * Pipes all events emitted by `stream` into `subject`.
215- */
183+ /** Pipes all events emitted by `stream` into `subject`.s */
216184function pipeTo < T > ( stream : Rx . Observable < T > , subject : Rx . Subject < T > ) {
217185 stream . subscribe ( ( event ) => subject . next ( event ) ) ;
218186}
0 commit comments