aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/concurrently/dist/src/command.d.ts
blob: 84c6298a9b9f7611dafc08709464885f19223d7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
import * as Rx from 'rxjs';
import { EventEmitter, Writable } from 'stream';
/**
 * Identifier for a command; if string, it's the command's name, if number, it's the index.
 */
export type CommandIdentifier = string | number;
export interface CommandInfo {
    /**
     * Command's name.
     */
    name: string;
    /**
     * Which command line the command has.
     */
    command: string;
    /**
     * Which environment variables should the spawned process have.
     */
    env?: Record<string, unknown>;
    /**
     * The current working directory of the process when spawned.
     */
    cwd?: string;
    /**
     * Color to use on prefix of the command.
     */
    prefixColor?: string;
    /**
     * Output command in raw format.
     */
    raw?: boolean;
}
export interface CloseEvent {
    command: CommandInfo;
    /**
     * The command's index among all commands ran.
     */
    index: number;
    /**
     * Whether the command exited because it was killed.
     */
    killed: boolean;
    /**
     * The exit code or signal for the command.
     */
    exitCode: string | number;
    timings: {
        startDate: Date;
        endDate: Date;
        durationSeconds: number;
    };
}
export interface TimerEvent {
    startDate: Date;
    endDate?: Date;
}
/**
 * Subtype of NodeJS's child_process including only what's actually needed for a command to work.
 */
export type ChildProcess = EventEmitter & Pick<BaseChildProcess, 'pid' | 'stdin' | 'stdout' | 'stderr'>;
/**
 * Interface for a function that must kill the process with `pid`, optionally sending `signal` to it.
 */
export type KillProcess = (pid: number, signal?: string) => void;
/**
 * Interface for a function that spawns a command and returns its child process instance.
 */
export type SpawnCommand = (command: string, options: SpawnOptions) => ChildProcess;
export declare class Command implements CommandInfo {
    private readonly killProcess;
    private readonly spawn;
    private readonly spawnOpts;
    readonly index: number;
    /** @inheritdoc */
    readonly name: string;
    /** @inheritdoc */
    readonly command: string;
    /** @inheritdoc */
    readonly prefixColor?: string;
    /** @inheritdoc */
    readonly env: Record<string, unknown>;
    /** @inheritdoc */
    readonly cwd?: string;
    readonly close: Rx.Subject<CloseEvent>;
    readonly error: Rx.Subject<unknown>;
    readonly stdout: Rx.Subject<Buffer>;
    readonly stderr: Rx.Subject<Buffer>;
    readonly timer: Rx.Subject<TimerEvent>;
    process?: ChildProcess;
    stdin?: Writable;
    pid?: number;
    killed: boolean;
    exited: boolean;
    /** @deprecated */
    get killable(): boolean;
    constructor({ index, name, command, prefixColor, env, cwd }: CommandInfo & {
        index: number;
    }, spawnOpts: SpawnOptions, spawn: SpawnCommand, killProcess: KillProcess);
    /**
     * Starts this command, piping output, error and close events onto the corresponding observables.
     */
    start(): void;
    /**
     * Kills this command, optionally specifying a signal to send to it.
     */
    kill(code?: string): void;
    /**
     * Detects whether a command can be killed.
     *
     * Also works as a type guard on the input `command`.
     */
    static canKill(command: Command): command is Command & {
        pid: number;
        process: ChildProcess;
    };
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage