UNPKG

3.88 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Writable } from 'stream';
3import { CloseEvent, Command, CommandInfo, KillProcess, SpawnCommand } from './command';
4import { SuccessCondition } from './completion-listener';
5import { FlowController } from './flow-control/flow-controller';
6import { Logger } from './logger';
7/**
8 * A command that is to be passed into `concurrently()`.
9 * If value is a string, then that's the command's command line.
10 * Fine grained options can be defined by using the object format.
11 */
12export type ConcurrentlyCommandInput = string | ({
13 command: string;
14} & Partial<CommandInfo>);
15export type ConcurrentlyResult = {
16 /**
17 * All commands created and ran by concurrently.
18 */
19 commands: Command[];
20 /**
21 * A promise that resolves when concurrently ran successfully according to the specified
22 * success condition, or reject otherwise.
23 *
24 * Both the resolved and rejected value is the list of all command's close events.
25 */
26 result: Promise<CloseEvent[]>;
27};
28export type ConcurrentlyOptions = {
29 logger?: Logger;
30 /**
31 * Which stream should the commands output be written to.
32 */
33 outputStream?: Writable;
34 /**
35 * Whether the output should be ordered as if the commands were run sequentially.
36 */
37 group?: boolean;
38 /**
39 * A comma-separated list of chalk colors or a string for available styles listed below to use on prefixes.
40 * If there are more commands than colors, the last color will be repeated.
41 *
42 * Available modifiers:
43 * - `reset`, `bold`, `dim`, `italic`, `underline`, `inverse`, `hidden`, `strikethrough`
44 *
45 * Available colors:
46 * - `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`,
47 * any hex values for colors (e.g. `#23de43`) or `auto` for an automatically picked color
48 *
49 * Available background colors:
50 * - `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
51 *
52 * @see {@link https://www.npmjs.com/package/chalk} for more information.
53 */
54 prefixColors?: string | string[];
55 /**
56 * Maximum number of commands to run at once.
57 * Exact number or a percent of CPUs available (for example "50%").
58 *
59 * If undefined, then all processes will start in parallel.
60 * Setting this value to 1 will achieve sequential running.
61 */
62 maxProcesses?: number | string;
63 /**
64 * Whether commands should be spawned in raw mode.
65 * Defaults to false.
66 */
67 raw?: boolean;
68 /**
69 * The current working directory of commands which didn't specify one.
70 * Defaults to `process.cwd()`.
71 */
72 cwd?: string;
73 /**
74 * @see CompletionListener
75 */
76 successCondition?: SuccessCondition;
77 /**
78 * Which flow controllers should be applied on commands spawned by concurrently.
79 * Defaults to an empty array.
80 */
81 controllers: FlowController[];
82 /**
83 * A function that will spawn commands.
84 * Defaults to the `spawn-command` module.
85 */
86 spawn: SpawnCommand;
87 /**
88 * A function that will kill processes.
89 * Defaults to the `tree-kill` module.
90 */
91 kill: KillProcess;
92 /**
93 * Signal to send to killed processes.
94 */
95 killSignal?: string;
96 /**
97 * List of additional arguments passed that will get replaced in each command.
98 * If not defined, no argument replacing will happen.
99 *
100 * @see ExpandArguments
101 */
102 additionalArguments?: string[];
103};
104/**
105 * Core concurrently functionality -- spawns the given commands concurrently and
106 * returns the commands themselves + the result according to the specified success condition.
107 *
108 * @see CompletionListener
109 */
110export declare function concurrently(baseCommands: ConcurrentlyCommandInput[], baseOptions?: Partial<ConcurrentlyOptions>): ConcurrentlyResult;