Skip to content

Commit

Permalink
GH-3791 don't swallow output from shell tasks
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Koehnlein <[email protected]>
  • Loading branch information
JanKoehnlein committed Dec 10, 2018
1 parent 29dd2bd commit 5843534
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
21 changes: 6 additions & 15 deletions packages/task/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ Each task configuration looks like this:
"-alR"
],
"windows": {
"command": "cmd.exe",
"command": "dir",
"args": [
"/c",
"dir",
"/s"
]
}
Expand All @@ -35,7 +33,7 @@ Each task configuration looks like this:

*args*: a list of strings, each one being one argument to pass to the command.

*windows*: by default, *command* and *ars* above is used on all platforms. However it's not always possible to express a task in the same way, both on Unix and Windows. The command and/or arguments may be different, for example. If a task needs to work on both Linux/MacOS and Windows, it can be better to have two separate process options. If *windows* is defined, it will be used instead of *command* and *ars*, when a task is executed on a Windows backend.
*windows*: by default, *command* and *ars* above is used on all platforms. However it's not always possible to express a task in the same way, both on Unix and Windows. The command and/or arguments may be different, for example. If a task needs to work on both Linux/MacOS and Windows, it can be better to have two separate process options. If *windows* is defined, it will be used instead of *command* and *args*, when a task is executed on a Windows backend.

Here is a sample tasks.json that can be used to test tasks. Just add this content under the theia source directory, in directory `.theia`:
``` json
Expand All @@ -53,10 +51,8 @@ Here is a sample tasks.json that can be used to test tasks. Just add this conten
"3"
],
"windows": {
"command": "cmd.exe",
"command": "task.bat",
"args": [
"/c",
"task.bat",
"abc"
]
}
Expand All @@ -68,11 +64,8 @@ Here is a sample tasks.json that can be used to test tasks. Just add this conten
"command": "./task-long-running",
"args": [],
"windows": {
"command": "cmd.exe",
"args": [
"/c",
"task-long-running.bat"
]
"command": "task-long-running.bat",
"args": []
}
},
{
Expand All @@ -84,10 +77,8 @@ Here is a sample tasks.json that can be used to test tasks. Just add this conten
"-alR"
],
"windows": {
"command": "cmd.exe",
"command": "dir",
"args": [
"/c",
"dir",
"/s"
]
}
Expand Down
20 changes: 10 additions & 10 deletions packages/task/src/node/process/process-task-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import { FileUri } from '@theia/core/lib/node';
import {
TerminalProcess,
RawProcess,
TerminalProcessOptions,
RawProcessOptions,
RawProcessFactory,
TerminalProcessFactory
RawProcessFactory
} from '@theia/process/lib/node';
import URI from '@theia/core/lib/common/uri';
import { TaskFactory } from './process-task';
Expand All @@ -32,6 +30,7 @@ import { Task } from '../task';
import { TaskConfiguration } from '../../common/task-protocol';
import * as fs from 'fs';
import * as path from 'path';
import { ShellProcessFactory, ShellProcessOptions } from '@theia/terminal/lib/node/shell-process';

/**
* Task runner that runs a task as a process or a command inside a shell.
Expand All @@ -45,8 +44,8 @@ export class ProcessTaskRunner implements TaskRunner {
@inject(RawProcessFactory)
protected readonly rawProcessFactory: RawProcessFactory;

@inject(TerminalProcessFactory)
protected readonly terminalProcessFactory: TerminalProcessFactory;
@inject(ShellProcessFactory)
protected readonly shellProcessFactory: ShellProcessFactory;

@inject(TaskFactory)
protected readonly taskFactory: TaskFactory;
Expand Down Expand Up @@ -109,12 +108,13 @@ export class ProcessTaskRunner implements TaskRunner {
});
} else {
// all Task types without specific TaskRunner will be run as a shell process e.g.: npm, gulp, etc.
this.logger.debug('Task: creating underlying terminal process');
proc = this.terminalProcessFactory(<TerminalProcessOptions>{
command: command,
args: args,
options: options
this.logger.debug('Task: creating underlying shell process');
proc = this.shellProcessFactory(<ShellProcessOptions>{
rootURI: options.cwd,
env: options.env
});
const commandLine = [command, ...args].join(' ') + '\r';
proc.write(commandLine);
}
return this.taskFactory({
label: taskConfig.label,
Expand Down

0 comments on commit 5843534

Please sign in to comment.