diff --git a/packages/task/src/node/task-runner.ts b/packages/task/src/node/task-runner.ts index e33767eff75f4..aa53a768b8a48 100644 --- a/packages/task/src/node/task-runner.ts +++ b/packages/task/src/node/task-runner.ts @@ -84,14 +84,20 @@ export class TaskRunnerRegistry { } /** - * Retrieves the {@link TaskRunner} registered for the specified Task type. - * @param type the task type. + * Looks for a registered {@link TaskRunner} for each of the task types in sequence and returns the first that is found + * If no task runner is registered for any of the types, the default runner is returned. + * @param types the task types. * - * @returns the registered {@link TaskRunner} or a default runner if none is registered for the specified type. + * @returns the registered {@link TaskRunner} or a default runner if none is registered for the specified types. */ - getRunner(type: string): TaskRunner { - const runner = this.runners.get(type); - return runner ? runner : this.defaultRunner; + getRunner(...types: string[]): TaskRunner { + for (const type of types) { + const runner = this.runners.get(type); + if (runner) { + return runner; + } + } + return this.defaultRunner; } /** diff --git a/packages/task/src/node/task-server.ts b/packages/task/src/node/task-server.ts index 40385c56ceb05..798aad5bd3068 100644 --- a/packages/task/src/node/task-server.ts +++ b/packages/task/src/node/task-server.ts @@ -90,7 +90,7 @@ export class TaskServerImpl implements TaskServer, Disposable { } async run(taskConfiguration: TaskConfiguration, ctx?: string, option?: RunTaskOption): Promise { - const runner = this.runnerRegistry.getRunner(taskConfiguration.taskType); + const runner = this.runnerRegistry.getRunner(taskConfiguration.type, taskConfiguration.taskType); const task = await runner.run(taskConfiguration, ctx); if (!this.toDispose.has(task.id)) {