From 6f0df2489b3e9fb1d414f2a7cb856b49524f1ecf Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 3 Dec 2019 12:43:41 +0200 Subject: [PATCH] Fix Signed-off-by: Anatoliy Bazko --- .../plugin-ext/src/plugin/type-converters.ts | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/packages/plugin-ext/src/plugin/type-converters.ts b/packages/plugin-ext/src/plugin/type-converters.ts index c3ab75958fb51..44fd5a00dcd01 100644 --- a/packages/plugin-ext/src/plugin/type-converters.ts +++ b/packages/plugin-ext/src/plugin/type-converters.ts @@ -23,7 +23,6 @@ import { ResourceTextEditDto, ResourceFileEditDto, TaskDto, - ProcessTaskDto, PickOpenItem, Plugin } from '../common/plugin-api-rpc'; @@ -631,16 +630,15 @@ export function fromTask(task: theia.Task): TaskDto | undefined { return taskDto; } - const processTaskDto = taskDto as ProcessTaskDto; if (taskDefinition.type === 'shell' || types.ShellExecution.is(execution)) { - return fromShellExecution(execution, processTaskDto); + return fromShellExecution(execution, taskDto); } if (taskDefinition.type === 'process' || types.ProcessExecution.is(execution)) { - return fromProcessExecution(execution, processTaskDto); + return fromProcessExecution(execution, taskDto); } - return processTaskDto; + return taskDto; } export function toTask(taskDto: TaskDto): theia.Task { @@ -690,41 +688,35 @@ export function toTask(taskDto: TaskDto): theia.Task { return result; } -export function fromProcessExecution(execution: theia.ProcessExecution, processTaskDto: ProcessTaskDto): ProcessTaskDto { - processTaskDto.command = execution.process; - processTaskDto.args = execution.args; +export function fromProcessExecution(execution: theia.ProcessExecution, taskDto: TaskDto): TaskDto { + taskDto.command = execution.process; + taskDto.args = execution.args; const options = execution.options; if (options) { - processTaskDto.options = options; + taskDto.options = options; } - return processTaskDto; + return taskDto; } -export function fromShellExecution(execution: theia.ShellExecution, processTaskDto: ProcessTaskDto): ProcessTaskDto { +export function fromShellExecution(execution: theia.ShellExecution, taskDto: TaskDto): TaskDto { const options = execution.options; if (options) { - processTaskDto.options = getShellExecutionOptions(options); + taskDto.options = getShellExecutionOptions(options); } const commandLine = execution.commandLine; if (commandLine) { - const args = commandLine.split(' '); - const taskCommand = args.shift(); - - if (taskCommand) { - processTaskDto.command = taskCommand; - } - - processTaskDto.args = args; - return processTaskDto; + taskDto.command = commandLine; + taskDto.args = []; + return taskDto; } const command = execution.command; if (typeof command === 'string') { - processTaskDto.command = command; - processTaskDto.args = getShellArgs(execution.args); - return processTaskDto; + taskDto.command = command; + taskDto.args = getShellArgs(execution.args); + return taskDto; } else { throw new Error('Converting ShellQuotedString command is not implemented'); }