未验证 提交 fc9d770f 编写于 作者: A Alex Ross 提交者: GitHub

Add sequential task dependency property (#74460)

Fixes #58718
上级 676368aa
......@@ -50,7 +50,7 @@ const taskIdentifier: IJSONSchema = {
properties: {
type: {
type: 'string',
description: nls.localize('JsonSchema.tasks.dependsOn.identifier', 'The task indentifier.')
description: nls.localize('JsonSchema.tasks.dependsOn.identifier', 'The task identifier.')
}
}
};
......@@ -77,6 +77,17 @@ const dependsOn: IJSONSchema = {
]
};
const dependsOrder: IJSONSchema = {
type: 'string',
enum: ['parallel', 'sequence'],
enumDescriptions: [
nls.localize('JsonSchema.tasks.dependsOrder.parallel', 'Run all dependsOn tasks in parallel.'),
nls.localize('JsonSchema.tasks.dependsOrder.sequence', 'Run all dependsOn tasks in sequence.'),
],
default: 'parallel',
description: nls.localize('JsonSchema.tasks.dependsOrder', 'Determines the order of the dependsOn tasks for this task. Note that this property is not recursive.')
};
const presentation: IJSONSchema = {
type: 'object',
default: {
......@@ -353,6 +364,7 @@ let taskConfiguration: IJSONSchema = {
},
runOptions: Objects.deepClone(runOptions),
dependsOn: Objects.deepClone(dependsOn),
dependsOrder: Objects.deepClone(dependsOrder)
}
};
......@@ -405,6 +417,7 @@ taskDescriptionProperties.command = Objects.deepClone(command);
taskDescriptionProperties.args = Objects.deepClone(args);
taskDescriptionProperties.isShellCommand = Objects.deepClone(shellCommand);
taskDescriptionProperties.dependsOn = dependsOn;
taskDescriptionProperties.dependsOrder = dependsOrder;
taskDescriptionProperties.identifier = Objects.deepClone(identifier);
taskDescriptionProperties.type = Objects.deepClone(taskType);
taskDescriptionProperties.presentation = Objects.deepClone(presentation);
......
......@@ -312,6 +312,11 @@ export interface ConfigurationProperties {
*/
dependsOn?: string | TaskIdentifier | Array<string | TaskIdentifier>;
/**
* The order the dependsOn tasks should be executed in.
*/
dependsOrder?: string;
/**
* Controls the behavior of the used terminal
*/
......@@ -1214,6 +1219,18 @@ namespace TaskDependency {
}
}
namespace DependsOrder {
export function from(order: string | undefined): Tasks.DependsOrder {
switch (order) {
case Tasks.DependsOrder.sequence:
return Tasks.DependsOrder.sequence;
case Tasks.DependsOrder.parallel:
default:
return Tasks.DependsOrder.parallel;
}
}
}
namespace ConfigurationProperties {
const properties: MetaData<Tasks.ConfigurationProperties, any>[] = [
......@@ -1269,6 +1286,7 @@ namespace ConfigurationProperties {
result.dependsOn = dependsOnValue ? [dependsOnValue] : undefined;
}
}
result.dependsOrder = DependsOrder.from(external.dependsOrder);
if (includeCommandOptions && (external.presentation !== undefined || (external as LegacyCommandProperties).terminal !== undefined)) {
result.presentation = CommandConfiguration.PresentationOptions.from(external, context);
}
......@@ -1389,7 +1407,6 @@ namespace ConfiguringTask {
}
namespace CustomTask {
export function from(this: void, external: CustomTask, context: ParseContext, index: number): Tasks.CustomTask | undefined {
if (!external) {
return undefined;
......
......@@ -431,6 +431,11 @@ export const enum GroupType {
user = 'user'
}
export const enum DependsOrder {
parallel = 'parallel',
sequence = 'sequence'
}
export interface ConfigurationProperties {
/**
......@@ -478,6 +483,11 @@ export interface ConfigurationProperties {
*/
dependsOn?: TaskDependency[];
/**
* The order the dependsOn tasks should be executed in.
*/
dependsOrder?: DependsOrder;
/**
* The problem watchers to use for this task
*/
......
......@@ -32,7 +32,7 @@ import { IOutputService } from 'vs/workbench/contrib/output/common/output';
import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEventKind, ProblemHandlingStrategy } from 'vs/workbench/contrib/tasks/common/problemCollectors';
import {
Task, CustomTask, ContributedTask, RevealKind, CommandOptions, ShellConfiguration, RuntimeType, PanelKind,
TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope, RevealProblemKind
TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope, RevealProblemKind, DependsOrder
} from 'vs/workbench/contrib/tasks/common/tasks';
import {
ITaskSystem, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, ITaskResolver,
......@@ -333,10 +333,11 @@ export class TerminalTaskSystem implements ITaskSystem {
return Promise.all<TaskTerminateResponse>(promises);
}
private executeTask(task: Task, resolver: ITaskResolver, trigger: string): Promise<ITaskSummary> {
private async executeTask(task: Task, resolver: ITaskResolver, trigger: string): Promise<ITaskSummary> {
let promises: Promise<ITaskSummary>[] = [];
if (task.configurationProperties.dependsOn) {
task.configurationProperties.dependsOn.forEach((dependency) => {
for (let index in task.configurationProperties.dependsOn) {
const dependency = task.configurationProperties.dependsOn[index];
let dependencyTask = resolver.resolve(dependency.workspaceFolder, dependency.task!);
if (dependencyTask) {
let key = dependencyTask.getMapKey();
......@@ -345,6 +346,9 @@ export class TerminalTaskSystem implements ITaskSystem {
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.DependsOnStarted, task));
promise = this.executeTask(dependencyTask, resolver, trigger);
}
if (task.configurationProperties.dependsOrder === DependsOrder.sequence) {
promise = Promise.resolve(await promise);
}
promises.push(promise);
} else {
this.log(nls.localize('dependencyFailed',
......@@ -354,7 +358,7 @@ export class TerminalTaskSystem implements ITaskSystem {
));
this.showOutput();
}
});
}
}
if ((ContributedTask.is(task) || CustomTask.is(task)) && (task.command)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册