Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Task related refactoring #7696

Merged
merged 2 commits into from
May 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@ export class TaskService implements TaskConfigurationClient {
*/
async run(source: string, taskLabel: string, scope?: string): Promise<TaskInfo | undefined> {
let task: TaskConfiguration | undefined;
task = await this.getProvidedTask(source, taskLabel, scope);
if (!task) { // if a detected task cannot be found, search from tasks.json
task = this.taskConfigurations.getTask(source, taskLabel);
task = this.taskConfigurations.getTask(source, taskLabel);
if (!task) { // if a configured task cannot be found, search from detected tasks
task = await this.getProvidedTask(source, taskLabel, scope);
if (!task && scope) { // find from the customized detected tasks
task = await this.taskConfigurations.getCustomizedTask(scope, taskLabel);
}
Expand Down Expand Up @@ -506,20 +506,33 @@ export class TaskService implements TaskConfigurationClient {
}
}

const tasks = await this.getWorkspaceTasks(task._scope);
const resolvedMatchers = await this.resolveProblemMatchers(task, customizationObject);
const runTaskOption: RunTaskOption = {
customization: { ...customizationObject, ...{ problemMatcher: resolvedMatchers } }
};

if (task.dependsOn) {
return this.runCompoundTask(task, runTaskOption);
} else {
return this.runTask(task, runTaskOption).catch(error => {
console.error('Error at launching task', error);
return undefined;
});
}
}

async runCompoundTask(task: TaskConfiguration, option?: RunTaskOption): Promise<TaskInfo | undefined> {
const tasks = await this.getWorkspaceTasks(task._scope);
try {
const rootNode = new TaskNode(task, [], []);
this.detectDirectedAcyclicGraph(task, rootNode, tasks);
} catch (error) {
this.logger.error(error.message);
console.error(`Error at launching task '${task.label}'`, error);
this.messageService.error(error.message);
return undefined;
}
return this.runTasksGraph(task, tasks, {
customization: { ...customizationObject, ...{ problemMatcher: resolvedMatchers } }
}).catch(error => {
console.log(error.message);
return this.runTasksGraph(task, tasks, option).catch(error => {
console.error(`Error at launching task '${task.label}'`, error);
return undefined;
});
}
Expand Down