From e4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sat, 28 Jun 2025 17:26:46 -0700 Subject: initial commit: scaffolding --- .../dist/src/flow-control/kill-others.js | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 node_modules/concurrently/dist/src/flow-control/kill-others.js (limited to 'node_modules/concurrently/dist/src/flow-control/kill-others.js') 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; -- cgit v1.2.3