aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/concurrently/dist/src/flow-control
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/concurrently/dist/src/flow-control')
-rw-r--r--node_modules/concurrently/dist/src/flow-control/flow-controller.d.ts13
-rw-r--r--node_modules/concurrently/dist/src/flow-control/flow-controller.js2
-rw-r--r--node_modules/concurrently/dist/src/flow-control/input-handler.d.ts30
-rw-r--r--node_modules/concurrently/dist/src/flow-control/input-handler.js90
-rw-r--r--node_modules/concurrently/dist/src/flow-control/kill-on-signal.d.ts17
-rw-r--r--node_modules/concurrently/dist/src/flow-control/kill-on-signal.js36
-rw-r--r--node_modules/concurrently/dist/src/flow-control/kill-others.d.ts20
-rw-r--r--node_modules/concurrently/dist/src/flow-control/kill-others.js35
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-error.d.ts15
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-error.js20
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-exit.d.ts15
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-exit.js18
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-output.d.ts15
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-output.js19
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-timings.d.ts31
-rw-r--r--node_modules/concurrently/dist/src/flow-control/log-timings.js92
-rw-r--r--node_modules/concurrently/dist/src/flow-control/restart-process.d.ts22
-rw-r--r--node_modules/concurrently/dist/src/flow-control/restart-process.js76
18 files changed, 566 insertions, 0 deletions
diff --git a/node_modules/concurrently/dist/src/flow-control/flow-controller.d.ts b/node_modules/concurrently/dist/src/flow-control/flow-controller.d.ts
new file mode 100644
index 0000000..b518aad
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/flow-controller.d.ts
@@ -0,0 +1,13 @@
+import { Command } from '../command';
+/**
+ * Interface for a class that controls and/or watches the behavior of commands.
+ *
+ * This may include logging their output, creating interactions between them, or changing when they
+ * actually finish.
+ */
+export interface FlowController {
+ handle(commands: Command[]): {
+ commands: Command[];
+ onFinish?: () => void;
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/flow-controller.js b/node_modules/concurrently/dist/src/flow-control/flow-controller.js
new file mode 100644
index 0000000..c8ad2e5
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/flow-controller.js
@@ -0,0 +1,2 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/concurrently/dist/src/flow-control/input-handler.d.ts b/node_modules/concurrently/dist/src/flow-control/input-handler.d.ts
new file mode 100644
index 0000000..3a7ee5a
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/input-handler.d.ts
@@ -0,0 +1,30 @@
+/// <reference types="node" />
+import { Readable } from 'stream';
+import { Command, CommandIdentifier } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+/**
+ * Sends input from concurrently through to commands.
+ *
+ * Input can start with a command identifier, in which case it will be sent to that specific command.
+ * For instance, `0:bla` will send `bla` to command at index `0`, and `server:stop` will send `stop`
+ * to command with name `server`.
+ *
+ * If the input doesn't start with a command identifier, it is then always sent to the default target.
+ */
+export declare class InputHandler implements FlowController {
+ private readonly logger;
+ private readonly defaultInputTarget;
+ private readonly inputStream?;
+ private readonly pauseInputStreamOnFinish;
+ constructor({ defaultInputTarget, inputStream, pauseInputStreamOnFinish, logger, }: {
+ inputStream?: Readable;
+ logger: Logger;
+ defaultInputTarget?: CommandIdentifier;
+ pauseInputStreamOnFinish?: boolean;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ onFinish?: () => void | undefined;
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/input-handler.js b/node_modules/concurrently/dist/src/flow-control/input-handler.js
new file mode 100644
index 0000000..76c552f
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/input-handler.js
@@ -0,0 +1,90 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.InputHandler = void 0;
+const Rx = __importStar(require("rxjs"));
+const operators_1 = require("rxjs/operators");
+const defaults = __importStar(require("../defaults"));
+/**
+ * Sends input from concurrently through to commands.
+ *
+ * Input can start with a command identifier, in which case it will be sent to that specific command.
+ * For instance, `0:bla` will send `bla` to command at index `0`, and `server:stop` will send `stop`
+ * to command with name `server`.
+ *
+ * If the input doesn't start with a command identifier, it is then always sent to the default target.
+ */
+class InputHandler {
+ constructor({ defaultInputTarget, inputStream, pauseInputStreamOnFinish, logger, }) {
+ this.logger = logger;
+ this.defaultInputTarget = defaultInputTarget || defaults.defaultInputTarget;
+ this.inputStream = inputStream;
+ this.pauseInputStreamOnFinish = pauseInputStreamOnFinish !== false;
+ }
+ handle(commands) {
+ const { inputStream } = this;
+ if (!inputStream) {
+ return { commands };
+ }
+ const commandsMap = new Map();
+ for (const command of commands) {
+ commandsMap.set(command.index.toString(), command);
+ commandsMap.set(command.name, command);
+ }
+ Rx.fromEvent(inputStream, 'data')
+ .pipe((0, operators_1.map)((data) => String(data)))
+ .subscribe((data) => {
+ let command, input;
+ const dataParts = data.split(/:(.+)/s);
+ let target = dataParts[0];
+ if (dataParts.length > 1 && (command = commandsMap.get(target))) {
+ input = dataParts[1];
+ }
+ else {
+ // If `target` does not match a registered command,
+ // fallback to `defaultInputTarget` and forward the whole input data
+ target = this.defaultInputTarget.toString();
+ command = commandsMap.get(target);
+ input = data;
+ }
+ if (command && command.stdin) {
+ command.stdin.write(input);
+ }
+ else {
+ this.logger.logGlobalEvent(`Unable to find command "${target}", or it has no stdin open\n`);
+ }
+ });
+ return {
+ commands,
+ onFinish: () => {
+ if (this.pauseInputStreamOnFinish) {
+ // https://github.com/kimmobrunfeldt/concurrently/issues/252
+ inputStream.pause();
+ }
+ },
+ };
+ }
+}
+exports.InputHandler = InputHandler;
diff --git a/node_modules/concurrently/dist/src/flow-control/kill-on-signal.d.ts b/node_modules/concurrently/dist/src/flow-control/kill-on-signal.d.ts
new file mode 100644
index 0000000..d706694
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/kill-on-signal.d.ts
@@ -0,0 +1,17 @@
+/// <reference types="node" />
+import EventEmitter from 'events';
+import { Command } from '../command';
+import { FlowController } from './flow-controller';
+/**
+ * Watches the main concurrently process for signals and sends the same signal down to each spawned
+ * command.
+ */
+export declare class KillOnSignal implements FlowController {
+ private readonly process;
+ constructor({ process }: {
+ process: EventEmitter;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/kill-on-signal.js b/node_modules/concurrently/dist/src/flow-control/kill-on-signal.js
new file mode 100644
index 0000000..716a9bf
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/kill-on-signal.js
@@ -0,0 +1,36 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.KillOnSignal = void 0;
+const operators_1 = require("rxjs/operators");
+/**
+ * Watches the main concurrently process for signals and sends the same signal down to each spawned
+ * command.
+ */
+class KillOnSignal {
+ constructor({ process }) {
+ this.process = process;
+ }
+ handle(commands) {
+ let caughtSignal;
+ ['SIGINT', 'SIGTERM', 'SIGHUP'].forEach((signal) => {
+ this.process.on(signal, () => {
+ caughtSignal = signal;
+ commands.forEach((command) => command.kill(signal));
+ });
+ });
+ return {
+ commands: commands.map((command) => {
+ const closeStream = command.close.pipe((0, operators_1.map)((exitInfo) => {
+ const exitCode = caughtSignal === 'SIGINT' ? 0 : exitInfo.exitCode;
+ return { ...exitInfo, exitCode };
+ }));
+ return new Proxy(command, {
+ get(target, prop) {
+ return prop === 'close' ? closeStream : target[prop];
+ },
+ });
+ }),
+ };
+ }
+}
+exports.KillOnSignal = KillOnSignal;
diff --git a/node_modules/concurrently/dist/src/flow-control/kill-others.d.ts b/node_modules/concurrently/dist/src/flow-control/kill-others.d.ts
new file mode 100644
index 0000000..f10b7bb
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/kill-others.d.ts
@@ -0,0 +1,20 @@
+import { Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+export type ProcessCloseCondition = 'failure' | 'success';
+/**
+ * Sends a SIGTERM signal to all commands when one of the commands exits with a matching condition.
+ */
+export declare class KillOthers implements FlowController {
+ private readonly logger;
+ private readonly conditions;
+ private readonly killSignal;
+ constructor({ logger, conditions, killSignal, }: {
+ logger: Logger;
+ conditions: ProcessCloseCondition | ProcessCloseCondition[];
+ killSignal: string | undefined;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/kill-others.js b/node_modules/concurrently/dist/src/flow-control/kill-others.js
new file mode 100644
index 0000000..1751677
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/kill-others.js
@@ -0,0 +1,35 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.KillOthers = void 0;
+const lodash_1 = __importDefault(require("lodash"));
+const operators_1 = require("rxjs/operators");
+const command_1 = require("../command");
+/**
+ * Sends a SIGTERM signal to all commands when one of the commands exits with a matching condition.
+ */
+class KillOthers {
+ constructor({ logger, conditions, killSignal, }) {
+ this.logger = logger;
+ this.conditions = lodash_1.default.castArray(conditions);
+ this.killSignal = killSignal;
+ }
+ handle(commands) {
+ const conditions = this.conditions.filter((condition) => condition === 'failure' || condition === 'success');
+ if (!conditions.length) {
+ return { commands };
+ }
+ const closeStates = commands.map((command) => command.close.pipe((0, operators_1.map)(({ exitCode }) => exitCode === 0 ? 'success' : 'failure'), (0, operators_1.filter)((state) => conditions.includes(state))));
+ closeStates.forEach((closeState) => closeState.subscribe(() => {
+ const killableCommands = commands.filter((command) => command_1.Command.canKill(command));
+ if (killableCommands.length) {
+ this.logger.logGlobalEvent(`Sending ${this.killSignal || 'SIGTERM'} to other processes..`);
+ killableCommands.forEach((command) => command.kill(this.killSignal));
+ }
+ }));
+ return { commands };
+ }
+}
+exports.KillOthers = KillOthers;
diff --git a/node_modules/concurrently/dist/src/flow-control/log-error.d.ts b/node_modules/concurrently/dist/src/flow-control/log-error.d.ts
new file mode 100644
index 0000000..8eac6dd
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-error.d.ts
@@ -0,0 +1,15 @@
+import { Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+/**
+ * Logs when commands failed executing, e.g. due to the executable not existing in the system.
+ */
+export declare class LogError implements FlowController {
+ private readonly logger;
+ constructor({ logger }: {
+ logger: Logger;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/log-error.js b/node_modules/concurrently/dist/src/flow-control/log-error.js
new file mode 100644
index 0000000..8fc7210
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-error.js
@@ -0,0 +1,20 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LogError = void 0;
+/**
+ * Logs when commands failed executing, e.g. due to the executable not existing in the system.
+ */
+class LogError {
+ constructor({ logger }) {
+ this.logger = logger;
+ }
+ handle(commands) {
+ commands.forEach((command) => command.error.subscribe((event) => {
+ this.logger.logCommandEvent(`Error occurred when executing command: ${command.command}`, command);
+ const errorText = String(event instanceof Error ? event.stack || event : event);
+ this.logger.logCommandEvent(errorText, command);
+ }));
+ return { commands };
+ }
+}
+exports.LogError = LogError;
diff --git a/node_modules/concurrently/dist/src/flow-control/log-exit.d.ts b/node_modules/concurrently/dist/src/flow-control/log-exit.d.ts
new file mode 100644
index 0000000..47b8718
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-exit.d.ts
@@ -0,0 +1,15 @@
+import { Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+/**
+ * Logs the exit code/signal of commands.
+ */
+export declare class LogExit implements FlowController {
+ private readonly logger;
+ constructor({ logger }: {
+ logger: Logger;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/log-exit.js b/node_modules/concurrently/dist/src/flow-control/log-exit.js
new file mode 100644
index 0000000..6fe396d
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-exit.js
@@ -0,0 +1,18 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LogExit = void 0;
+/**
+ * Logs the exit code/signal of commands.
+ */
+class LogExit {
+ constructor({ logger }) {
+ this.logger = logger;
+ }
+ handle(commands) {
+ commands.forEach((command) => command.close.subscribe(({ exitCode }) => {
+ this.logger.logCommandEvent(`${command.command} exited with code ${exitCode}`, command);
+ }));
+ return { commands };
+ }
+}
+exports.LogExit = LogExit;
diff --git a/node_modules/concurrently/dist/src/flow-control/log-output.d.ts b/node_modules/concurrently/dist/src/flow-control/log-output.d.ts
new file mode 100644
index 0000000..6c916de
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-output.d.ts
@@ -0,0 +1,15 @@
+import { Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+/**
+ * Logs the stdout and stderr output of commands.
+ */
+export declare class LogOutput implements FlowController {
+ private readonly logger;
+ constructor({ logger }: {
+ logger: Logger;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/log-output.js b/node_modules/concurrently/dist/src/flow-control/log-output.js
new file mode 100644
index 0000000..486a25b
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-output.js
@@ -0,0 +1,19 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LogOutput = void 0;
+/**
+ * Logs the stdout and stderr output of commands.
+ */
+class LogOutput {
+ constructor({ logger }) {
+ this.logger = logger;
+ }
+ handle(commands) {
+ commands.forEach((command) => {
+ command.stdout.subscribe((text) => this.logger.logCommandText(text.toString(), command));
+ command.stderr.subscribe((text) => this.logger.logCommandText(text.toString(), command));
+ });
+ return { commands };
+ }
+}
+exports.LogOutput = LogOutput;
diff --git a/node_modules/concurrently/dist/src/flow-control/log-timings.d.ts b/node_modules/concurrently/dist/src/flow-control/log-timings.d.ts
new file mode 100644
index 0000000..a847707
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-timings.d.ts
@@ -0,0 +1,31 @@
+import { CloseEvent, Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+type TimingInfo = {
+ name: string;
+ duration: string;
+ 'exit code': string | number;
+ killed: boolean;
+ command: string;
+};
+/**
+ * Logs timing information about commands as they start/stop and then a summary when all commands finish.
+ */
+export declare class LogTimings implements FlowController {
+ static mapCloseEventToTimingInfo({ command, timings, killed, exitCode, }: CloseEvent): TimingInfo;
+ private readonly logger?;
+ private readonly timestampFormat;
+ constructor({ logger, timestampFormat, }: {
+ logger?: Logger;
+ timestampFormat?: string;
+ });
+ private printExitInfoTimingTable;
+ handle(commands: Command[]): {
+ commands: Command[];
+ onFinish?: undefined;
+ } | {
+ commands: Command[];
+ onFinish: () => void;
+ };
+}
+export {};
diff --git a/node_modules/concurrently/dist/src/flow-control/log-timings.js b/node_modules/concurrently/dist/src/flow-control/log-timings.js
new file mode 100644
index 0000000..9c8879d
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/log-timings.js
@@ -0,0 +1,92 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LogTimings = void 0;
+const assert = __importStar(require("assert"));
+const format_1 = __importDefault(require("date-fns/format"));
+const lodash_1 = __importDefault(require("lodash"));
+const Rx = __importStar(require("rxjs"));
+const operators_1 = require("rxjs/operators");
+const defaults = __importStar(require("../defaults"));
+/**
+ * Logs timing information about commands as they start/stop and then a summary when all commands finish.
+ */
+class LogTimings {
+ static mapCloseEventToTimingInfo({ command, timings, killed, exitCode, }) {
+ const readableDurationMs = (timings.endDate.getTime() - timings.startDate.getTime()).toLocaleString();
+ return {
+ name: command.name,
+ duration: readableDurationMs,
+ 'exit code': exitCode,
+ killed,
+ command: command.command,
+ };
+ }
+ constructor({ logger, timestampFormat = defaults.timestampFormat, }) {
+ this.logger = logger;
+ this.timestampFormat = timestampFormat;
+ }
+ printExitInfoTimingTable(exitInfos) {
+ assert.ok(this.logger);
+ const exitInfoTable = (0, lodash_1.default)(exitInfos)
+ .sortBy(({ timings }) => timings.durationSeconds)
+ .reverse()
+ .map(LogTimings.mapCloseEventToTimingInfo)
+ .value();
+ this.logger.logGlobalEvent('Timings:');
+ this.logger.logTable(exitInfoTable);
+ return exitInfos;
+ }
+ handle(commands) {
+ const { logger } = this;
+ if (!logger) {
+ return { commands };
+ }
+ // individual process timings
+ commands.forEach((command) => {
+ command.timer.subscribe(({ startDate, endDate }) => {
+ if (!endDate) {
+ const formattedStartDate = (0, format_1.default)(startDate, this.timestampFormat);
+ logger.logCommandEvent(`${command.command} started at ${formattedStartDate}`, command);
+ }
+ else {
+ const durationMs = endDate.getTime() - startDate.getTime();
+ const formattedEndDate = (0, format_1.default)(endDate, this.timestampFormat);
+ logger.logCommandEvent(`${command.command} stopped at ${formattedEndDate} after ${durationMs.toLocaleString()}ms`, command);
+ }
+ });
+ });
+ // overall summary timings
+ const closeStreams = commands.map((command) => command.close);
+ const finished = new Rx.Subject();
+ const allProcessesClosed = Rx.merge(...closeStreams).pipe((0, operators_1.bufferCount)(closeStreams.length), (0, operators_1.take)(1), (0, operators_1.combineLatestWith)(finished));
+ allProcessesClosed.subscribe(([exitInfos]) => this.printExitInfoTimingTable(exitInfos));
+ return { commands, onFinish: () => finished.next() };
+ }
+}
+exports.LogTimings = LogTimings;
diff --git a/node_modules/concurrently/dist/src/flow-control/restart-process.d.ts b/node_modules/concurrently/dist/src/flow-control/restart-process.d.ts
new file mode 100644
index 0000000..735d8d5
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/restart-process.d.ts
@@ -0,0 +1,22 @@
+import * as Rx from 'rxjs';
+import { Command } from '../command';
+import { Logger } from '../logger';
+import { FlowController } from './flow-controller';
+/**
+ * Restarts commands that fail up to a defined number of times.
+ */
+export declare class RestartProcess implements FlowController {
+ private readonly logger;
+ private readonly scheduler?;
+ readonly delay: number;
+ readonly tries: number;
+ constructor({ delay, tries, logger, scheduler, }: {
+ delay?: number;
+ tries?: number;
+ logger: Logger;
+ scheduler?: Rx.SchedulerLike;
+ });
+ handle(commands: Command[]): {
+ commands: Command[];
+ };
+}
diff --git a/node_modules/concurrently/dist/src/flow-control/restart-process.js b/node_modules/concurrently/dist/src/flow-control/restart-process.js
new file mode 100644
index 0000000..79131ce
--- /dev/null
+++ b/node_modules/concurrently/dist/src/flow-control/restart-process.js
@@ -0,0 +1,76 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.RestartProcess = void 0;
+const Rx = __importStar(require("rxjs"));
+const operators_1 = require("rxjs/operators");
+const defaults = __importStar(require("../defaults"));
+/**
+ * Restarts commands that fail up to a defined number of times.
+ */
+class RestartProcess {
+ constructor({ delay, tries, logger, scheduler, }) {
+ this.logger = logger;
+ this.delay = delay != null ? +delay : defaults.restartDelay;
+ this.tries = tries != null ? +tries : defaults.restartTries;
+ this.tries = this.tries < 0 ? Infinity : this.tries;
+ this.scheduler = scheduler;
+ }
+ handle(commands) {
+ if (this.tries === 0) {
+ return { commands };
+ }
+ commands
+ .map((command) => command.close.pipe((0, operators_1.take)(this.tries), (0, operators_1.takeWhile)(({ exitCode }) => exitCode !== 0)))
+ .map((failure, index) => Rx.merge(
+ // Delay the emission (so that the restarts happen on time),
+ // explicitly telling the subscriber that a restart is needed
+ failure.pipe((0, operators_1.delay)(this.delay, this.scheduler), (0, operators_1.map)(() => true)),
+ // Skip the first N emissions (as these would be duplicates of the above),
+ // meaning it will be empty because of success, or failed all N times,
+ // and no more restarts should be attempted.
+ failure.pipe((0, operators_1.skip)(this.tries), (0, operators_1.map)(() => false), (0, operators_1.defaultIfEmpty)(false))).subscribe((restart) => {
+ const command = commands[index];
+ if (restart) {
+ this.logger.logCommandEvent(`${command.command} restarted`, command);
+ command.start();
+ }
+ }));
+ return {
+ commands: commands.map((command) => {
+ const closeStream = command.close.pipe((0, operators_1.filter)(({ exitCode }, emission) => {
+ // We let all success codes pass, and failures only after restarting won't happen again
+ return exitCode === 0 || emission >= this.tries;
+ }));
+ return new Proxy(command, {
+ get(target, prop) {
+ return prop === 'close' ? closeStream : target[prop];
+ },
+ });
+ }),
+ };
+ }
+}
+exports.RestartProcess = RestartProcess;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage