Skip to content

Commit

Permalink
Fix execution of a task when Resolver returns undefined
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
  • Loading branch information
RomanNikitenko committed Apr 29, 2021
1 parent 7047f57 commit 2aa654d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/plugin-ext/src/main/browser/tasks-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export class TasksMainImpl implements TasksMain, Disposable {

async $executeTask(taskDto: TaskDto): Promise<TaskExecutionDto | undefined> {
const taskConfig = this.toTaskConfiguration(taskDto);
if (!taskConfig) {
return undefined;
}
const taskInfo = await this.taskService.runTask(taskConfig);
if (taskInfo) {
return {
Expand Down Expand Up @@ -185,9 +188,9 @@ export class TasksMainImpl implements TasksMain, Disposable {
return {
provideTasks: () =>
this.proxy.$provideTasks(handle).then(v =>
v!.map(taskDto =>
this.toTaskConfiguration(taskDto)
)
v!
.map(taskDto => this.toTaskConfiguration(taskDto))
.filter(taskConfig => taskConfig !== undefined) as TaskConfiguration[]
)
};
}
Expand All @@ -196,12 +199,15 @@ export class TasksMainImpl implements TasksMain, Disposable {
return {
resolveTask: taskConfig =>
this.proxy.$resolveTask(handle, this.fromTaskConfiguration(taskConfig)).then(v =>
this.toTaskConfiguration(v!)
this.toTaskConfiguration(v) || taskConfig
)
};
}

protected toTaskConfiguration(taskDto: TaskDto): TaskConfiguration {
protected toTaskConfiguration(taskDto?: TaskDto): TaskConfiguration | undefined {
if (!taskDto) {
return undefined;
}
const { group, presentation, scope, source, ...common } = taskDto;
const partialConfig: Partial<TaskConfiguration> = {};
if (presentation) {
Expand Down

0 comments on commit 2aa654d

Please sign in to comment.