Skip to content

Commit 19aecfd

Browse files
committed
Addresses microsoft#27672: Task Detection For Gulp
1 parent 41463b1 commit 19aecfd

3 files changed

Lines changed: 46 additions & 11 deletions

File tree

extensions/grunt/src/main.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
7373
});
7474
}
7575

76+
let _channel: vscode.OutputChannel;
77+
function getOutputChannel(): vscode.OutputChannel {
78+
if (!_channel) {
79+
_channel = vscode.window.createOutputChannel('Grunt Auto Detection');
80+
}
81+
return _channel;
82+
}
83+
7684
async function getGruntTasks(): Promise<vscode.Task[]> {
7785
let workspaceRoot = vscode.workspace.rootPath;
7886
let emptyTasks: vscode.Task[] = [];
@@ -95,12 +103,11 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
95103
}
96104

97105
let commandLine = `${command} --help --no-color`;
98-
let channel = vscode.window.createOutputChannel('tasks');
99106
try {
100107
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
101108
if (stderr) {
102-
channel.appendLine(stderr);
103-
channel.show(true);
109+
getOutputChannel().appendLine(stderr);
110+
getOutputChannel().show(true);
104111
}
105112
let result: vscode.Task[] = [];
106113
if (stdout) {
@@ -166,11 +173,15 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
166173
}
167174
return result;
168175
} catch (err) {
176+
let channel = getOutputChannel();
169177
if (err.stderr) {
170178
channel.appendLine(err.stderr);
171-
channel.show(true);
179+
}
180+
if (err.stdout) {
181+
channel.appendLine(err.stdout);
172182
}
173183
channel.appendLine(localize('execFailed', 'Auto detecting Grunt failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
184+
channel.show(true);
174185
return emptyTasks;
175186
}
176187
}

extensions/gulp/src/main.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
7373
});
7474
}
7575

76+
let _channel: vscode.OutputChannel;
77+
function getOutputChannel(): vscode.OutputChannel {
78+
if (!_channel) {
79+
_channel = vscode.window.createOutputChannel('Gulp Auto Detection');
80+
}
81+
return _channel;
82+
}
83+
7684
async function getGulpTasks(): Promise<vscode.Task[]> {
7785
let workspaceRoot = vscode.workspace.rootPath;
7886
let emptyTasks: vscode.Task[] = [];
@@ -98,12 +106,11 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
98106
}
99107

100108
let commandLine = `${gulpCommand} --tasks-simple --no-color`;
101-
let channel = vscode.window.createOutputChannel('tasks');
102109
try {
103110
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
104-
if (stderr) {
105-
channel.appendLine(stderr);
106-
channel.show(true);
111+
if (stderr && stderr.length > 0) {
112+
getOutputChannel().appendLine(stderr);
113+
getOutputChannel().show(true);
107114
}
108115
let result: vscode.Task[] = [];
109116
if (stdout) {
@@ -137,10 +144,15 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
137144
}
138145
return result;
139146
} catch (err) {
147+
let channel = getOutputChannel();
140148
if (err.stderr) {
141149
channel.appendLine(err.stderr);
142150
}
151+
if (err.stdout) {
152+
channel.appendLine(err.stdout);
153+
}
143154
channel.appendLine(localize('execFailed', 'Auto detecting gulp failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
155+
channel.show(true);
144156
return emptyTasks;
145157
}
146158
}

extensions/jake/src/main.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
7373
});
7474
}
7575

76+
let _channel: vscode.OutputChannel;
77+
function getOutputChannel(): vscode.OutputChannel {
78+
if (!_channel) {
79+
_channel = vscode.window.createOutputChannel('Jake Auto Detection');
80+
}
81+
return _channel;
82+
}
83+
7684
async function getJakeTasks(): Promise<vscode.Task[]> {
7785
let workspaceRoot = vscode.workspace.rootPath;
7886
let emptyTasks: vscode.Task[] = [];
@@ -98,12 +106,11 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
98106
}
99107

100108
let commandLine = `${jakeCommand} --tasks`;
101-
let channel = vscode.window.createOutputChannel('tasks');
102109
try {
103110
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
104111
if (stderr) {
105-
channel.appendLine(stderr);
106-
channel.show(true);
112+
getOutputChannel().appendLine(stderr);
113+
getOutputChannel().show(true);
107114
}
108115
let result: vscode.Task[] = [];
109116
if (stdout) {
@@ -142,10 +149,15 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
142149
}
143150
return result;
144151
} catch (err) {
152+
let channel = getOutputChannel();
145153
if (err.stderr) {
146154
channel.appendLine(err.stderr);
147155
}
156+
if (err.stdout) {
157+
channel.appendLine(err.stdout);
158+
}
148159
channel.appendLine(localize('execFailed', 'Auto detecting Jake failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
160+
channel.show(true);
149161
return emptyTasks;
150162
}
151163
}

0 commit comments

Comments
 (0)