@@ -2,59 +2,39 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
2
2
import * as Rx from 'rxjs' ;
3
3
import { EventEmitter , Writable } from 'stream' ;
4
4
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.*/
8
6
export type CommandIdentifier = string | number ;
9
7
10
8
export interface CommandInfo {
11
- /**
12
- * Command's name.
13
- */
9
+ /** Command's name. */
14
10
name : string ;
15
11
16
- /**
17
- * Which command line the command has.
18
- */
12
+ /** Which command line the command has. */
19
13
command : string ;
20
14
21
- /**
22
- * Which environment variables should the spawned process have.
23
- */
15
+ /** Which environment variables should the spawned process have.*/
24
16
env ?: Record < string , unknown > ;
25
17
26
- /**
27
- * The current working directory of the process when spawned.
28
- */
18
+ /** The current working directory of the process when spawned.*/
29
19
cwd ?: string ;
30
20
31
- /**
32
- * Color to use on prefix of the command.
33
- */
21
+ /** Color to use on prefix of the command.*/
34
22
prefixColor ?: string ;
35
23
36
- /**
37
- * Output command in raw format.
38
- */
24
+ /** Output command in raw format.*/
39
25
raw ?: boolean ;
40
26
}
41
27
42
28
export interface CloseEvent {
43
29
command : CommandInfo ;
44
30
45
- /**
46
- * The command's index among all commands ran.
47
- */
31
+ /** The command's index among all commands ran.*/
48
32
index : number ;
49
33
50
- /**
51
- * Whether the command exited because it was killed.
52
- */
34
+ /** Whether the command exited because it was killed.*/
53
35
killed : boolean ;
54
36
55
- /**
56
- * The exit code or signal for the command.
57
- */
37
+ /** The exit code or signal for the command.*/
58
38
exitCode : string | number ;
59
39
timings : {
60
40
startDate : Date ;
@@ -68,20 +48,14 @@ export interface TimerEvent {
68
48
endDate ?: Date ;
69
49
}
70
50
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. */
74
52
export type ChildProcess = EventEmitter &
75
53
Pick < BaseChildProcess , 'pid' | 'stdin' | 'stdout' | 'stderr' > ;
76
54
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. */
80
56
export type KillProcess = ( pid : number , signal ?: string ) => void ;
81
57
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. */
85
59
export type SpawnCommand = ( command : string , options : SpawnOptions ) => ChildProcess ;
86
60
87
61
export class Command implements CommandInfo {
@@ -139,9 +113,7 @@ export class Command implements CommandInfo {
139
113
this . spawnOpts = spawnOpts ;
140
114
}
141
115
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. */
145
117
start ( ) {
146
118
const child = this . spawn ( this . command , this . spawnOpts ) ;
147
119
this . process = child ;
@@ -190,9 +162,7 @@ export class Command implements CommandInfo {
190
162
this . stdin = child . stdin || undefined ;
191
163
}
192
164
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. */
196
166
kill ( code ?: string ) {
197
167
if ( Command . canKill ( this ) ) {
198
168
this . killed = true ;
@@ -210,9 +180,7 @@ export class Command implements CommandInfo {
210
180
}
211
181
}
212
182
213
- /**
214
- * Pipes all events emitted by `stream` into `subject`.
215
- */
183
+ /** Pipes all events emitted by `stream` into `subject`.s */
216
184
function pipeTo < T > ( stream : Rx . Observable < T > , subject : Rx . Subject < T > ) {
217
185
stream . subscribe ( ( event ) => subject . next ( event ) ) ;
218
186
}
0 commit comments