Skip to content

Commit

Permalink
Pass abort controller/signal from main concurrently function
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavohenke committed Jan 10, 2024
1 parent 07553f8 commit 6e1407b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseConcurrentlyOptions, 'abortSignal'> & {
// Logger options
/**
* Which command(s) should have their output hidden.
Expand Down Expand Up @@ -103,6 +103,8 @@ export default (
timestampFormat: options.timestampFormat,
});

const abortController = new AbortController();

return concurrently(commands, {
maxProcesses: options.maxProcesses,
raw: options.raw,
Expand All @@ -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 }),
Expand All @@ -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,
Expand All @@ -132,6 +135,7 @@ export default (
logger,
conditions: options.killOthers || [],
killSignal: options.killSignal,
abortController,
}),
new LogTimings({
logger: options.timings ? logger : undefined,
Expand Down

0 comments on commit 6e1407b

Please sign in to comment.