From 0cef38e85dc4e62a7fc30292de1c36303ff963b8 Mon Sep 17 00:00:00 2001 From: Mohammad Saleh Fadaei Date: Sun, 7 Nov 2021 10:30:21 +0330 Subject: [PATCH] fix: use parrent-like add methode in pipleine --- src/runners/pipeline-tasks-runner.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/runners/pipeline-tasks-runner.ts b/src/runners/pipeline-tasks-runner.ts index 33cf80c..6d68757 100644 --- a/src/runners/pipeline-tasks-runner.ts +++ b/src/runners/pipeline-tasks-runner.ts @@ -14,11 +14,12 @@ export class PipelineTasksRunner extends BaseTasksRunner { } public add(...tasks: PipelineTask[]): number { - if (this.status !== "open") { - throw new Error("task runner is not open to add new task"); + // can't add tasks if the runner is closed + if (this.status === "open") { + return this.tasks.push(...tasks) - 1; } - return this.tasks.push(...tasks) - 1; + return -1; } public remove(start: number, count = 1): PipelineTask[] {