concurrently 6.5.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -43
- package/dist/bin/concurrently.d.ts +2 -0
- package/dist/bin/concurrently.js +218 -0
- package/dist/bin/epilogue.d.ts +1 -0
- package/dist/bin/epilogue.js +81 -0
- package/dist/src/command-parser/command-parser.d.ts +19 -0
- package/dist/src/command-parser/command-parser.js +2 -0
- package/dist/src/command-parser/expand-arguments.d.ts +12 -0
- package/dist/src/command-parser/expand-arguments.js +40 -0
- package/dist/src/command-parser/expand-npm-shortcut.d.ts +8 -0
- package/dist/src/command-parser/expand-npm-shortcut.js +20 -0
- package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
- package/dist/src/command-parser/expand-npm-wildcard.js +82 -0
- package/dist/src/command-parser/strip-quotes.d.ts +10 -0
- package/dist/src/command-parser/strip-quotes.js +18 -0
- package/dist/src/command.d.ts +104 -0
- package/{src → dist/src}/command.js +54 -30
- package/dist/src/completion-listener.d.ts +39 -0
- package/dist/src/completion-listener.js +74 -0
- package/dist/src/concurrently.d.ts +90 -0
- package/dist/src/concurrently.js +124 -0
- package/dist/src/defaults.d.ts +62 -0
- package/dist/src/defaults.js +67 -0
- package/dist/src/flow-control/flow-controller.d.ts +13 -0
- package/dist/src/flow-control/flow-controller.js +2 -0
- package/dist/src/flow-control/input-handler.d.ts +33 -0
- package/dist/src/flow-control/input-handler.js +73 -0
- package/dist/src/flow-control/kill-on-signal.d.ts +17 -0
- package/{src → dist/src}/flow-control/kill-on-signal.js +15 -13
- package/dist/src/flow-control/kill-others.d.ts +18 -0
- package/dist/src/flow-control/kill-others.js +35 -0
- package/dist/src/flow-control/log-error.d.ts +15 -0
- package/dist/src/flow-control/log-error.js +21 -0
- package/dist/src/flow-control/log-exit.d.ts +15 -0
- package/dist/src/flow-control/log-exit.js +19 -0
- package/dist/src/flow-control/log-output.d.ts +15 -0
- package/{src → dist/src}/flow-control/log-output.js +13 -5
- package/dist/src/flow-control/log-timings.d.ts +27 -0
- package/dist/src/flow-control/log-timings.js +88 -0
- package/dist/src/flow-control/restart-process.d.ts +22 -0
- package/dist/src/flow-control/restart-process.js +71 -0
- package/dist/src/get-spawn-opts.d.ts +30 -0
- package/dist/src/get-spawn-opts.js +11 -0
- package/dist/src/index.d.ts +74 -0
- package/dist/src/index.js +70 -0
- package/dist/src/logger.d.ts +72 -0
- package/{src → dist/src}/logger.js +77 -58
- package/dist/src/output-writer.d.ts +19 -0
- package/dist/src/output-writer.js +69 -0
- package/index.js +6 -68
- package/index.mjs +9 -0
- package/package.json +42 -12
- package/bin/concurrently.js +0 -186
- package/bin/concurrently.spec.js +0 -428
- package/bin/epilogue.txt +0 -46
- package/src/command-parser/expand-npm-shortcut.js +0 -13
- package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
- package/src/command-parser/expand-npm-wildcard.js +0 -52
- package/src/command-parser/expand-npm-wildcard.spec.js +0 -104
- package/src/command-parser/strip-quotes.js +0 -12
- package/src/command-parser/strip-quotes.spec.js +0 -20
- package/src/command.spec.js +0 -275
- package/src/completion-listener.js +0 -39
- package/src/completion-listener.spec.js +0 -89
- package/src/concurrently.js +0 -116
- package/src/concurrently.spec.js +0 -199
- package/src/defaults.js +0 -35
- package/src/flow-control/base-handler.js +0 -16
- package/src/flow-control/base-handler.spec.js +0 -22
- package/src/flow-control/input-handler.js +0 -50
- package/src/flow-control/input-handler.spec.js +0 -113
- package/src/flow-control/kill-on-signal.spec.js +0 -79
- package/src/flow-control/kill-others.js +0 -38
- package/src/flow-control/kill-others.spec.js +0 -66
- package/src/flow-control/log-error.js +0 -18
- package/src/flow-control/log-error.spec.js +0 -40
- package/src/flow-control/log-exit.js +0 -11
- package/src/flow-control/log-exit.spec.js +0 -36
- package/src/flow-control/log-output.spec.js +0 -41
- package/src/flow-control/log-timings.js +0 -64
- package/src/flow-control/log-timings.spec.js +0 -137
- package/src/flow-control/restart-process.js +0 -56
- package/src/flow-control/restart-process.spec.js +0 -139
- package/src/get-spawn-opts.js +0 -16
- package/src/get-spawn-opts.spec.js +0 -30
- package/src/logger.spec.js +0 -318
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.LogTimings = void 0;
|
|
26
|
+
const format_1 = __importDefault(require("date-fns/format"));
|
|
27
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
28
|
+
const Rx = __importStar(require("rxjs"));
|
|
29
|
+
const operators_1 = require("rxjs/operators");
|
|
30
|
+
const defaults = __importStar(require("../defaults"));
|
|
31
|
+
/**
|
|
32
|
+
* Logs timing information about commands as they start/stop and then a summary when all commands finish.
|
|
33
|
+
*/
|
|
34
|
+
class LogTimings {
|
|
35
|
+
constructor({ logger, timestampFormat = defaults.timestampFormat }) {
|
|
36
|
+
this.logger = logger;
|
|
37
|
+
this.timestampFormat = timestampFormat;
|
|
38
|
+
}
|
|
39
|
+
static mapCloseEventToTimingInfo({ command, timings, killed, exitCode }) {
|
|
40
|
+
const readableDurationMs = (timings.endDate.getTime() - timings.startDate.getTime()).toLocaleString();
|
|
41
|
+
return {
|
|
42
|
+
name: command.name,
|
|
43
|
+
duration: readableDurationMs,
|
|
44
|
+
'exit code': exitCode,
|
|
45
|
+
killed,
|
|
46
|
+
command: command.command,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
printExitInfoTimingTable(exitInfos) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const exitInfoTable = (0, lodash_1.default)(exitInfos)
|
|
52
|
+
.sortBy(({ timings }) => timings.durationSeconds)
|
|
53
|
+
.reverse()
|
|
54
|
+
.map(LogTimings.mapCloseEventToTimingInfo)
|
|
55
|
+
.value();
|
|
56
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.logGlobalEvent('Timings:');
|
|
57
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.logTable(exitInfoTable);
|
|
58
|
+
return exitInfos;
|
|
59
|
+
}
|
|
60
|
+
;
|
|
61
|
+
handle(commands) {
|
|
62
|
+
if (!this.logger) {
|
|
63
|
+
return { commands };
|
|
64
|
+
}
|
|
65
|
+
// individual process timings
|
|
66
|
+
commands.forEach(command => {
|
|
67
|
+
command.timer.subscribe(({ startDate, endDate }) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (!endDate) {
|
|
70
|
+
const formattedStartDate = (0, format_1.default)(startDate, this.timestampFormat);
|
|
71
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.logCommandEvent(`${command.command} started at ${formattedStartDate}`, command);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const durationMs = endDate.getTime() - startDate.getTime();
|
|
75
|
+
const formattedEndDate = (0, format_1.default)(endDate, this.timestampFormat);
|
|
76
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.logCommandEvent(`${command.command} stopped at ${formattedEndDate} after ${durationMs.toLocaleString()}ms`, command);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
// overall summary timings
|
|
81
|
+
const closeStreams = commands.map(command => command.close);
|
|
82
|
+
const allProcessesClosed = Rx.merge(...closeStreams).pipe((0, operators_1.bufferCount)(closeStreams.length), (0, operators_1.take)(1));
|
|
83
|
+
allProcessesClosed.subscribe((exitInfos) => this.printExitInfoTimingTable(exitInfos));
|
|
84
|
+
return { commands };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.LogTimings = LogTimings;
|
|
88
|
+
;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Rx from 'rxjs';
|
|
2
|
+
import { Command } from '../command';
|
|
3
|
+
import { Logger } from '../logger';
|
|
4
|
+
import { FlowController } from './flow-controller';
|
|
5
|
+
/**
|
|
6
|
+
* Restarts commands that fail up to a defined number of times.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RestartProcess implements FlowController {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly scheduler?;
|
|
11
|
+
readonly delay: number;
|
|
12
|
+
readonly tries: number;
|
|
13
|
+
constructor({ delay, tries, logger, scheduler }: {
|
|
14
|
+
delay?: number;
|
|
15
|
+
tries?: number;
|
|
16
|
+
logger: Logger;
|
|
17
|
+
scheduler?: Rx.SchedulerLike;
|
|
18
|
+
});
|
|
19
|
+
handle(commands: Command[]): {
|
|
20
|
+
commands: Command[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.RestartProcess = void 0;
|
|
23
|
+
const Rx = __importStar(require("rxjs"));
|
|
24
|
+
const operators_1 = require("rxjs/operators");
|
|
25
|
+
const defaults = __importStar(require("../defaults"));
|
|
26
|
+
/**
|
|
27
|
+
* Restarts commands that fail up to a defined number of times.
|
|
28
|
+
*/
|
|
29
|
+
class RestartProcess {
|
|
30
|
+
constructor({ delay, tries, logger, scheduler }) {
|
|
31
|
+
this.logger = logger;
|
|
32
|
+
this.delay = delay != null ? +delay : defaults.restartDelay;
|
|
33
|
+
this.tries = tries != null ? +tries : defaults.restartTries;
|
|
34
|
+
this.tries = this.tries < 0 ? Infinity : this.tries;
|
|
35
|
+
this.scheduler = scheduler;
|
|
36
|
+
}
|
|
37
|
+
handle(commands) {
|
|
38
|
+
if (this.tries === 0) {
|
|
39
|
+
return { commands };
|
|
40
|
+
}
|
|
41
|
+
commands.map(command => command.close.pipe((0, operators_1.take)(this.tries), (0, operators_1.takeWhile)(({ exitCode }) => exitCode !== 0))).map((failure, index) => Rx.merge(
|
|
42
|
+
// Delay the emission (so that the restarts happen on time),
|
|
43
|
+
// explicitly telling the subscriber that a restart is needed
|
|
44
|
+
failure.pipe((0, operators_1.delay)(this.delay, this.scheduler), (0, operators_1.mapTo)(true)),
|
|
45
|
+
// Skip the first N emissions (as these would be duplicates of the above),
|
|
46
|
+
// meaning it will be empty because of success, or failed all N times,
|
|
47
|
+
// and no more restarts should be attempted.
|
|
48
|
+
failure.pipe((0, operators_1.skip)(this.tries), (0, operators_1.mapTo)(false), (0, operators_1.defaultIfEmpty)(false))).subscribe(restart => {
|
|
49
|
+
const command = commands[index];
|
|
50
|
+
if (restart) {
|
|
51
|
+
this.logger.logCommandEvent(`${command.command} restarted`, command);
|
|
52
|
+
command.start();
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
return {
|
|
56
|
+
commands: commands.map(command => {
|
|
57
|
+
const closeStream = command.close.pipe((0, operators_1.filter)(({ exitCode }, emission) => {
|
|
58
|
+
// We let all success codes pass, and failures only after restarting won't happen again
|
|
59
|
+
return exitCode === 0 || emission >= this.tries;
|
|
60
|
+
}));
|
|
61
|
+
return new Proxy(command, {
|
|
62
|
+
get(target, prop) {
|
|
63
|
+
return prop === 'close' ? closeStream : target[prop];
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.RestartProcess = RestartProcess;
|
|
71
|
+
;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SpawnOptions } from 'child_process';
|
|
3
|
+
import supportsColor from 'supports-color';
|
|
4
|
+
export declare const getSpawnOpts: ({ colorSupport, cwd, process, raw, env, }: {
|
|
5
|
+
/**
|
|
6
|
+
* What the color support of the spawned processes should be.
|
|
7
|
+
* If set to `false`, then no colors should be output.
|
|
8
|
+
*
|
|
9
|
+
* Defaults to whatever the terminal's stdout support is.
|
|
10
|
+
*/
|
|
11
|
+
colorSupport?: Pick<supportsColor.supportsColor.Level, 'level'> | false;
|
|
12
|
+
/**
|
|
13
|
+
* The NodeJS process.
|
|
14
|
+
*/
|
|
15
|
+
process?: Pick<NodeJS.Process, 'cwd' | 'platform' | 'env'>;
|
|
16
|
+
/**
|
|
17
|
+
* A custom working directory to spawn processes in.
|
|
18
|
+
* Defaults to `process.cwd()`.
|
|
19
|
+
*/
|
|
20
|
+
cwd?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to customize the options for spawning processes in raw mode.
|
|
23
|
+
* Defaults to false.
|
|
24
|
+
*/
|
|
25
|
+
raw?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Map of custom environment variables to include in the spawn options.
|
|
28
|
+
*/
|
|
29
|
+
env?: Record<string, any>;
|
|
30
|
+
}) => SpawnOptions;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSpawnOpts = void 0;
|
|
7
|
+
const supports_color_1 = __importDefault(require("supports-color"));
|
|
8
|
+
const getSpawnOpts = ({ colorSupport = supports_color_1.default.stdout, cwd, process = global.process, raw = false, env = {}, }) => Object.assign({
|
|
9
|
+
cwd: cwd || process.cwd(),
|
|
10
|
+
}, raw && { stdio: 'inherit' }, /^win/.test(process.platform) && { detached: false }, { env: Object.assign(colorSupport ? { FORCE_COLOR: colorSupport.level } : {}, process.env, env) });
|
|
11
|
+
exports.getSpawnOpts = getSpawnOpts;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { CloseEvent, Command, CommandIdentifier, TimerEvent } from './command';
|
|
4
|
+
import { concurrently, ConcurrentlyCommandInput, ConcurrentlyOptions as BaseConcurrentlyOptions, ConcurrentlyResult } from './concurrently';
|
|
5
|
+
import { FlowController } from './flow-control/flow-controller';
|
|
6
|
+
import { InputHandler } from './flow-control/input-handler';
|
|
7
|
+
import { KillOnSignal } from './flow-control/kill-on-signal';
|
|
8
|
+
import { KillOthers, ProcessCloseCondition } from './flow-control/kill-others';
|
|
9
|
+
import { LogError } from './flow-control/log-error';
|
|
10
|
+
import { LogExit } from './flow-control/log-exit';
|
|
11
|
+
import { LogOutput } from './flow-control/log-output';
|
|
12
|
+
import { LogTimings } from './flow-control/log-timings';
|
|
13
|
+
import { RestartProcess } from './flow-control/restart-process';
|
|
14
|
+
import { Logger } from './logger';
|
|
15
|
+
export declare type ConcurrentlyOptions = BaseConcurrentlyOptions & {
|
|
16
|
+
/**
|
|
17
|
+
* Which command(s) should have their output hidden.
|
|
18
|
+
*/
|
|
19
|
+
hide?: CommandIdentifier | CommandIdentifier[];
|
|
20
|
+
/**
|
|
21
|
+
* The prefix format to use when logging a command's output.
|
|
22
|
+
* Defaults to the command's index.
|
|
23
|
+
*/
|
|
24
|
+
prefix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* How many characters should a prefix have at most, used when the prefix format is `command`.
|
|
27
|
+
*/
|
|
28
|
+
prefixLength?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether output should be formatted to include prefixes and whether "event" logs will be logged.
|
|
31
|
+
*/
|
|
32
|
+
raw?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Date format used when logging date/time.
|
|
35
|
+
* @see https://date-fns.org/v2.0.1/docs/format
|
|
36
|
+
*/
|
|
37
|
+
timestampFormat?: string;
|
|
38
|
+
defaultInputTarget?: CommandIdentifier;
|
|
39
|
+
inputStream?: Readable;
|
|
40
|
+
handleInput?: boolean;
|
|
41
|
+
pauseInputStreamOnFinish?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* How much time in milliseconds to wait before restarting a command.
|
|
44
|
+
*
|
|
45
|
+
* @see RestartProcess
|
|
46
|
+
*/
|
|
47
|
+
restartDelay?: number;
|
|
48
|
+
/**
|
|
49
|
+
* How many times commands should be restarted when they exit with a failure.
|
|
50
|
+
*
|
|
51
|
+
* @see RestartProcess
|
|
52
|
+
*/
|
|
53
|
+
restartTries?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Under which condition(s) should other commands be killed when the first one exits.
|
|
56
|
+
*
|
|
57
|
+
* @see KillOthers
|
|
58
|
+
*/
|
|
59
|
+
killOthers?: ProcessCloseCondition | ProcessCloseCondition[];
|
|
60
|
+
/**
|
|
61
|
+
* Whether to output timing information for processes.
|
|
62
|
+
*
|
|
63
|
+
* @see LogTimings
|
|
64
|
+
*/
|
|
65
|
+
timings?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* List of additional arguments passed that will get replaced in each command.
|
|
68
|
+
* If not defined, no argument replacing will happen.
|
|
69
|
+
*/
|
|
70
|
+
additionalArguments?: string[];
|
|
71
|
+
};
|
|
72
|
+
declare const _default: (commands: ConcurrentlyCommandInput[], options?: Partial<ConcurrentlyOptions>) => ConcurrentlyResult;
|
|
73
|
+
export default _default;
|
|
74
|
+
export { concurrently, ConcurrentlyCommandInput, ConcurrentlyResult, Logger, Command, CloseEvent, TimerEvent, CommandIdentifier, FlowController, InputHandler, KillOnSignal, KillOthers, LogError, LogExit, LogOutput, LogTimings, RestartProcess, };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestartProcess = exports.LogTimings = exports.LogOutput = exports.LogExit = exports.LogError = exports.KillOthers = exports.KillOnSignal = exports.InputHandler = exports.Command = exports.Logger = exports.concurrently = void 0;
|
|
4
|
+
const command_1 = require("./command");
|
|
5
|
+
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
|
|
6
|
+
const concurrently_1 = require("./concurrently");
|
|
7
|
+
Object.defineProperty(exports, "concurrently", { enumerable: true, get: function () { return concurrently_1.concurrently; } });
|
|
8
|
+
const input_handler_1 = require("./flow-control/input-handler");
|
|
9
|
+
Object.defineProperty(exports, "InputHandler", { enumerable: true, get: function () { return input_handler_1.InputHandler; } });
|
|
10
|
+
const kill_on_signal_1 = require("./flow-control/kill-on-signal");
|
|
11
|
+
Object.defineProperty(exports, "KillOnSignal", { enumerable: true, get: function () { return kill_on_signal_1.KillOnSignal; } });
|
|
12
|
+
const kill_others_1 = require("./flow-control/kill-others");
|
|
13
|
+
Object.defineProperty(exports, "KillOthers", { enumerable: true, get: function () { return kill_others_1.KillOthers; } });
|
|
14
|
+
const log_error_1 = require("./flow-control/log-error");
|
|
15
|
+
Object.defineProperty(exports, "LogError", { enumerable: true, get: function () { return log_error_1.LogError; } });
|
|
16
|
+
const log_exit_1 = require("./flow-control/log-exit");
|
|
17
|
+
Object.defineProperty(exports, "LogExit", { enumerable: true, get: function () { return log_exit_1.LogExit; } });
|
|
18
|
+
const log_output_1 = require("./flow-control/log-output");
|
|
19
|
+
Object.defineProperty(exports, "LogOutput", { enumerable: true, get: function () { return log_output_1.LogOutput; } });
|
|
20
|
+
const log_timings_1 = require("./flow-control/log-timings");
|
|
21
|
+
Object.defineProperty(exports, "LogTimings", { enumerable: true, get: function () { return log_timings_1.LogTimings; } });
|
|
22
|
+
const restart_process_1 = require("./flow-control/restart-process");
|
|
23
|
+
Object.defineProperty(exports, "RestartProcess", { enumerable: true, get: function () { return restart_process_1.RestartProcess; } });
|
|
24
|
+
const logger_1 = require("./logger");
|
|
25
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
26
|
+
exports.default = (commands, options = {}) => {
|
|
27
|
+
const logger = new logger_1.Logger({
|
|
28
|
+
hide: options.hide,
|
|
29
|
+
prefixFormat: options.prefix,
|
|
30
|
+
prefixLength: options.prefixLength,
|
|
31
|
+
raw: options.raw,
|
|
32
|
+
timestampFormat: options.timestampFormat,
|
|
33
|
+
});
|
|
34
|
+
return (0, concurrently_1.concurrently)(commands, {
|
|
35
|
+
maxProcesses: options.maxProcesses,
|
|
36
|
+
raw: options.raw,
|
|
37
|
+
successCondition: options.successCondition,
|
|
38
|
+
cwd: options.cwd,
|
|
39
|
+
logger,
|
|
40
|
+
outputStream: options.outputStream || process.stdout,
|
|
41
|
+
group: options.group,
|
|
42
|
+
controllers: [
|
|
43
|
+
new log_error_1.LogError({ logger }),
|
|
44
|
+
new log_output_1.LogOutput({ logger }),
|
|
45
|
+
new log_exit_1.LogExit({ logger }),
|
|
46
|
+
new input_handler_1.InputHandler({
|
|
47
|
+
logger,
|
|
48
|
+
defaultInputTarget: options.defaultInputTarget,
|
|
49
|
+
inputStream: options.inputStream || (options.handleInput && process.stdin),
|
|
50
|
+
pauseInputStreamOnFinish: options.pauseInputStreamOnFinish,
|
|
51
|
+
}),
|
|
52
|
+
new kill_on_signal_1.KillOnSignal({ process }),
|
|
53
|
+
new restart_process_1.RestartProcess({
|
|
54
|
+
logger,
|
|
55
|
+
delay: options.restartDelay,
|
|
56
|
+
tries: options.restartTries,
|
|
57
|
+
}),
|
|
58
|
+
new kill_others_1.KillOthers({
|
|
59
|
+
logger,
|
|
60
|
+
conditions: options.killOthers,
|
|
61
|
+
}),
|
|
62
|
+
new log_timings_1.LogTimings({
|
|
63
|
+
logger: options.timings ? logger : null,
|
|
64
|
+
timestampFormat: options.timestampFormat,
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
prefixColors: options.prefixColors || [],
|
|
68
|
+
additionalArguments: options.additionalArguments,
|
|
69
|
+
});
|
|
70
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as Rx from 'rxjs';
|
|
2
|
+
import { Command, CommandIdentifier } from './command';
|
|
3
|
+
export declare class Logger {
|
|
4
|
+
private readonly hide;
|
|
5
|
+
private readonly raw;
|
|
6
|
+
private readonly prefixFormat?;
|
|
7
|
+
private readonly prefixLength;
|
|
8
|
+
private readonly timestampFormat;
|
|
9
|
+
/**
|
|
10
|
+
* Last character emitted.
|
|
11
|
+
* If `undefined`, then nothing has been logged yet.
|
|
12
|
+
*/
|
|
13
|
+
private lastChar?;
|
|
14
|
+
/**
|
|
15
|
+
* Observable that emits when there's been output logged.
|
|
16
|
+
* If `command` is is `undefined`, then the log is for a global event.
|
|
17
|
+
*/
|
|
18
|
+
readonly output: Rx.Subject<{
|
|
19
|
+
command: Command | undefined;
|
|
20
|
+
text: string;
|
|
21
|
+
}>;
|
|
22
|
+
constructor({ hide, prefixFormat, prefixLength, raw, timestampFormat }: {
|
|
23
|
+
/**
|
|
24
|
+
* Which command(s) should have their output hidden.
|
|
25
|
+
*/
|
|
26
|
+
hide?: CommandIdentifier | CommandIdentifier[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether output should be formatted to include prefixes and whether "event" logs will be
|
|
29
|
+
* logged.
|
|
30
|
+
*/
|
|
31
|
+
raw?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The prefix format to use when logging a command's output.
|
|
34
|
+
* Defaults to the command's index.
|
|
35
|
+
*/
|
|
36
|
+
prefixFormat?: string;
|
|
37
|
+
/**
|
|
38
|
+
* How many characters should a prefix have at most, used when the prefix format is `command`.
|
|
39
|
+
*/
|
|
40
|
+
prefixLength?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Date format used when logging date/time.
|
|
43
|
+
* @see https://date-fns.org/v2.0.1/docs/format
|
|
44
|
+
*/
|
|
45
|
+
timestampFormat?: string;
|
|
46
|
+
});
|
|
47
|
+
private shortenText;
|
|
48
|
+
private getPrefixesFor;
|
|
49
|
+
getPrefix(command: Command): string;
|
|
50
|
+
colorText(command: Command, text: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Logs an event for a command (e.g. start, stop).
|
|
53
|
+
*
|
|
54
|
+
* If raw mode is on, then nothing is logged.
|
|
55
|
+
*/
|
|
56
|
+
logCommandEvent(text: string, command: Command): void;
|
|
57
|
+
logCommandText(text: string, command: Command): void;
|
|
58
|
+
/**
|
|
59
|
+
* Logs a global event (e.g. sending signals to processes).
|
|
60
|
+
*
|
|
61
|
+
* If raw mode is on, then nothing is logged.
|
|
62
|
+
*/
|
|
63
|
+
logGlobalEvent(text: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Logs a table from an input object array, like `console.table`.
|
|
66
|
+
*
|
|
67
|
+
* Each row is a single input item, and they are presented in the input order.
|
|
68
|
+
*/
|
|
69
|
+
logTable(tableContents: any[]): void;
|
|
70
|
+
log(prefix: string, text: string, command?: Command): void;
|
|
71
|
+
emit(command: Command | undefined, text: string): void;
|
|
72
|
+
}
|