Skip to content

Commit

Permalink
Fix task type is modified.
Browse files Browse the repository at this point in the history
Signed-off-by: Lewin Tan <e_tanhaiyang@163.com>
  • Loading branch information
shyshywhy authored and kittaakos committed Apr 6, 2021
1 parent d97d605 commit 2184352
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/tasks/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class TasksExtImpl implements TasksExt {
// If this task is a custom execution, then we need to save it away
// in the provided custom execution map that is cleaned up after the
// task is executed.
if (taskDto.type === 'customExecution') {
if (CustomExecution.is(task.execution!)) {
this.addCustomExecution(taskDto, false);
}
const executionDto = await this.proxy.$executeTask(taskDto);
Expand All @@ -177,7 +177,7 @@ export class TasksExtImpl implements TasksExt {
return adapter.provideTasks(token).then(tasks => {
if (tasks) {
for (const task of tasks) {
if (task.type === 'customExecution') {
if (task.type === 'customExecution' || task.taskType === 'customExecution') {
this.addCustomExecution(task, true);
}
}
Expand Down
11 changes: 5 additions & 6 deletions packages/plugin-ext/src/plugin/type-converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ export function fromTask(task: theia.Task): TaskDto | undefined {
return taskDto;
}

if (taskDefinition.type === 'shell' || types.ShellExecution.is(execution)) {
if (taskDefinition.taskType === 'shell' || types.ShellExecution.is(execution)) {
return fromShellExecution(<theia.ShellExecution>execution, taskDto);
}

if (taskDefinition.type === 'process' || types.ProcessExecution.is(execution)) {
if (taskDefinition.taskType === 'process' || types.ProcessExecution.is(execution)) {
return fromProcessExecution(<theia.ProcessExecution>execution, taskDto);
}

if (taskDefinition.type === 'customExecution' || types.CustomExecution.is(execution)) {
if (taskDefinition.taskType === 'customExecution' || types.CustomExecution.is(execution)) {
return fromCustomExecution(<theia.CustomExecution>execution, taskDto);
}

Expand All @@ -770,7 +770,7 @@ export function toTask(taskDto: TaskDto): theia.Task {
throw new Error('Task should be provided for converting');
}

const { type, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, ...properties } = taskDto;
const { type, taskType, label, source, scope, problemMatcher, detail, command, args, options, group, presentation, ...properties } = taskDto;
const result = {} as theia.Task;
result.name = label;
result.source = source;
Expand All @@ -788,9 +788,8 @@ export function toTask(taskDto: TaskDto): theia.Task {
result.scope = scope;
}

const taskType = type;
const taskDefinition: theia.TaskDefinition = {
type: taskType
type: type
};

result.definition = taskDefinition;
Expand Down
11 changes: 4 additions & 7 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1911,21 +1911,18 @@ export class Task {
private updateDefinitionBasedOnExecution(): void {
if (this.taskExecution instanceof ProcessExecution) {
Object.assign(this.taskDefinition, {
type: 'process',
id: this.taskExecution.computeId(),
taskType: this.taskDefinition!.type
taskType: 'process'
});
} else if (this.taskExecution instanceof ShellExecution) {
Object.assign(this.taskDefinition, {
type: 'shell',
id: this.taskExecution.computeId(),
taskType: this.taskDefinition!.type
taskType: 'shell'
});
} else if (this.taskExecution instanceof CustomExecution) {
Object.assign(this.taskDefinition, {
type: 'customExecution',
id: this.taskExecution.computeId(),
taskType: this.taskDefinition!.type
id: this.taskDefinition.id ? this.taskDefinition.id : this.taskExecution.computeId(),
taskType: 'customExecution'
});
} else {
Object.assign(this.taskDefinition, {
Expand Down
2 changes: 1 addition & 1 deletion packages/task/src/browser/process/process-task-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ProcessTaskResolver implements TaskResolver {
* sane default values. Also, resolve all known variables, e.g. `${workspaceFolder}`.
*/
async resolveTask(taskConfig: TaskConfiguration): Promise<TaskConfiguration> {
if (taskConfig.type !== 'process' && taskConfig.type !== 'shell') {
if (taskConfig.taskType !== 'process' && taskConfig.taskType !== 'shell') {
throw new Error('Unsupported task configuration type.');
}
const context = typeof taskConfig._scope === 'string' ? new URI(taskConfig._scope) : undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/task/src/node/task-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class TaskServerImpl implements TaskServer, Disposable {
}

async run(taskConfiguration: TaskConfiguration, ctx?: string, option?: RunTaskOption): Promise<TaskInfo> {
const runner = this.runnerRegistry.getRunner(taskConfiguration.type);
const runner = this.runnerRegistry.getRunner(taskConfiguration.taskType);
const task = await runner.run(taskConfiguration, ctx);

if (!this.toDispose.has(task.id)) {
Expand Down

0 comments on commit 2184352

Please sign in to comment.