diff --git a/src/concurrently.ts b/src/concurrently.ts index a8ec5232..e995939d 100644 --- a/src/concurrently.ts +++ b/src/concurrently.ts @@ -227,7 +227,7 @@ export function concurrently( } const result = new CompletionListener({ successCondition: options.successCondition }) - .listen(commands) + .listen(commands, options.abortSignal) .finally(() => { handleResult.onFinishCallbacks.forEach((onFinish) => onFinish()); }); diff --git a/src/index.ts b/src/index.ts index 3dce77b6..8737738c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ import { LogTimings } from './flow-control/log-timings'; import { RestartProcess } from './flow-control/restart-process'; import { Logger } from './logger'; -export type ConcurrentlyOptions = BaseConcurrentlyOptions & { +export type ConcurrentlyOptions = Omit & { // Logger options /** * Which command(s) should have their output hidden. @@ -103,6 +103,8 @@ export default ( timestampFormat: options.timestampFormat, }); + const abortController = new AbortController(); + return concurrently(commands, { maxProcesses: options.maxProcesses, raw: options.raw, @@ -111,6 +113,7 @@ export default ( logger, outputStream: options.outputStream || process.stdout, group: options.group, + abortSignal: abortController.signal, controllers: [ new LogError({ logger }), new LogOutput({ logger }), @@ -122,7 +125,7 @@ export default ( options.inputStream || (options.handleInput ? process.stdin : undefined), pauseInputStreamOnFinish: options.pauseInputStreamOnFinish, }), - new KillOnSignal({ process }), + new KillOnSignal({ process, abortController }), new RestartProcess({ logger, delay: options.restartDelay, @@ -132,6 +135,7 @@ export default ( logger, conditions: options.killOthers || [], killSignal: options.killSignal, + abortController, }), new LogTimings({ logger: options.timings ? logger : undefined,