Skip to content

Commit

Permalink
Cannot define multiple commands in tasks.json #981
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Jan 20, 2017
1 parent 4c58d0d commit 06072ef
Show file tree
Hide file tree
Showing 6 changed files with 952 additions and 606 deletions.
103 changes: 56 additions & 47 deletions src/vs/workbench/parts/tasks/common/taskSystem.ts
Expand Up @@ -71,6 +71,52 @@ export namespace ShowOutput {
}
}

export interface CommandOptions {
/**
* The current working directory of the executed program or shell.
* If omitted VSCode's current workspace root is used.
*/
cwd?: string;

/**
* The environment of the executed program or shell. If omitted
* the parent process' environment is used.
*/
env?: { [key: string]: string; };
}

export interface CommandConfiguration {
/**
* The command to execute
*/
name?: string;

/**
* Whether the command is a shell command or not
*/
isShellCommand?: boolean;

/**
* Additional command options.
*/
options?: CommandOptions;

/**
* Command arguments.
*/
args?: string[];

/**
* The task selector if needed.
*/
taskSelector?: string;

/**
* Controls whether the executed command is printed to the output windows as well.
*/
echo?: boolean;
}

/**
* A task description
*/
Expand All @@ -86,6 +132,11 @@ export interface TaskDescription {
*/
name: string;

/**
* The command configuration
*/
command: CommandConfiguration;

/**
* Suppresses the task name when calling the task using the task runner.
*/
Expand Down Expand Up @@ -113,74 +164,32 @@ export interface TaskDescription {
*/
showOutput: ShowOutput;

/**
* Controls whether the executed command is printed to the output windows as well.
*/
echoCommand?: boolean;

/**
* The problem watchers to use for this task
*/
problemMatchers?: ProblemMatcher[];
}

export interface CommandOptions {
/**
* The current working directory of the executed program or shell.
* If omitted VSCode's current workspace root is used.
*/
cwd?: string;

/**
* The environment of the executed program or shell. If omitted
* the parent process' environment is used.
*/
env?: { [key: string]: string; };
}


/**
* Describs the settings of a task runner
*/
export interface BaseTaskRunnerConfiguration {

/**
* The command to execute
*/
command?: string;

export interface TaskRunnerConfiguration {
/**
* Whether the task is a shell command or not
* The inferred build tasks
*/
isShellCommand?: boolean;

/**
* Additional command options
*/
options?: CommandOptions;
buildTasks: string[];

/**
* General args
* The inferred test tasks;
*/
args?: string[];
testTasks: string[];

/**
* The configured tasks
*/
tasks?: { [id: string]: TaskDescription; };
}

/**
* Describs the settings of a task runner
*/
export interface TaskRunnerConfiguration extends BaseTaskRunnerConfiguration {

/**
* The command to execute. Not optional.
*/
command: string;
}

export interface ITaskSummary {
/**
* Exit code of the process.
Expand Down
65 changes: 44 additions & 21 deletions src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
Expand Up @@ -669,6 +669,10 @@ class TaskService extends EventEmitter implements ITaskService {
lifecycleService.onWillShutdown(event => event.veto(this.beforeShutdown()));
}

public log(value: string): void {
this.outputChannel.append(value + '\n');
}

private disposeTaskSystemListeners(): void {
this.taskSystemListeners = dispose(this.taskSystemListeners);
}
Expand Down Expand Up @@ -744,11 +748,15 @@ class TaskService extends EventEmitter implements ITaskService {
throw new TaskError(Severity.Info, nls.localize('TaskSystem.noConfiguration', 'No task runner configured.'), TaskErrors.NotConfigured);
}
let result: ITaskSystem = null;
let parseResult = FileConfig.parse(<FileConfig.ExternalTaskRunnerConfiguration>config, this);
if (parseResult.validationStatus.isFatal()) {
throw new TaskError(Severity.Error, nls.localize('TaskSystem.fatalError', 'The provided task configuration has validation errors. See tasks output log for details.'), TaskErrors.ConfigValidationError);
}
if (this.isRunnerConfig(config)) {
result = new ProcessRunnerSystem(<FileConfig.ExternalTaskRunnerConfiguration>config, this.markerService, this.modelService, this.telemetryService, this.outputService, this.configurationResolverService, TaskService.OutputChannelId, clearOutput);
result = new ProcessRunnerSystem(parseResult.configuration, this.markerService, this.modelService, this.telemetryService, this.outputService, this.configurationResolverService, TaskService.OutputChannelId, clearOutput);
} else if (this.isTerminalConfig(config)) {
result = new TerminalTaskSystem(
<FileConfig.ExternalTaskRunnerConfiguration>config,
parseResult.configuration,
this.terminalService, this.outputService, this.markerService,
this.modelService, this.configurationResolverService, this.telemetryService,
TaskService.OutputChannelId
Expand Down Expand Up @@ -1041,6 +1049,26 @@ let schema: IJSONSchema =
'type': 'string',
'enum': ['always', 'silent', 'never']
},
'options': {
'type': 'object',
'description': nls.localize('JsonSchema.options', 'Additional command options'),
'properties': {
'cwd': {
'type': 'string',
'description': nls.localize('JsonSchema.options.cwd', 'The current working directory of the executed program or script. If omitted Code\'s current workspace root is used.')
},
'env': {
'type': 'object',
'additionalProperties': {
'type': 'string'
},
'description': nls.localize('JsonSchema.options.env', 'The environment of the executed program or shell. If omitted the parent process\' environment is used.')
}
},
'additionalProperties': {
'type': ['string', 'array', 'object']
}
},
'patternType': {
'anyOf': [
{
Expand Down Expand Up @@ -1256,24 +1284,7 @@ let schema: IJSONSchema =
}
},
'options': {
'type': 'object',
'description': nls.localize('JsonSchema.options', 'Additional command options'),
'properties': {
'cwd': {
'type': 'string',
'description': nls.localize('JsonSchema.options.cwd', 'The current working directory of the executed program or script. If omitted Code\'s current workspace root is used.')
},
'env': {
'type': 'object',
'additionalProperties': {
'type': 'string'
},
'description': nls.localize('JsonSchema.options.env', 'The environment of the executed program or shell. If omitted the parent process\' environment is used.')
}
},
'additionalProperties': {
'type': ['string', 'array', 'object']
}
'$ref': '#/definitions/options'
},
'showOutput': {
'$ref': '#/definitions/showOutputType',
Expand Down Expand Up @@ -1326,13 +1337,25 @@ let schema: IJSONSchema =
'type': 'string',
'description': nls.localize('JsonSchema.tasks.taskName', "The task's name")
},
'command': {
'type': 'string',
'description': nls.localize('JsonSchema.command', 'The command to be executed. Can be an external program or a shell command.')
},
'isShellCommand': {
'type': 'boolean',
'default': true,
'description': nls.localize('JsonSchema.shell', 'Specifies whether the command is a shell command or an external program. Defaults to false if omitted.')
},
'args': {
'type': 'array',
'description': nls.localize('JsonSchema.tasks.args', 'Additional arguments passed to the command when this task is invoked.'),
'description': nls.localize('JsonSchema.tasks.args', 'Arguments passed to the command when this task is invoked.'),
'items': {
'type': 'string'
}
},
'options': {
'$ref': '#/definitions/options'
},
'suppressTaskName': {
'type': 'boolean',
'description': nls.localize('JsonSchema.tasks.suppressTaskName', 'Controls whether the task name is added as an argument to the command. If omitted the globally defined value is used.'),
Expand Down

0 comments on commit 06072ef

Please sign in to comment.