Addresses #27672: Task Detection For Gulp

This commit is contained in:
Dirk Baeumer 2017-06-01 11:12:01 +02:00
parent 41463b1b56
commit 19aecfd367
3 changed files with 46 additions and 11 deletions

View file

@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
});
}
let _channel: vscode.OutputChannel;
function getOutputChannel(): vscode.OutputChannel {
if (!_channel) {
_channel = vscode.window.createOutputChannel('Grunt Auto Detection');
}
return _channel;
}
async function getGruntTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
@ -95,12 +103,11 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
}
let commandLine = `${command} --help --no-color`;
let channel = vscode.window.createOutputChannel('tasks');
try {
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
if (stderr) {
channel.appendLine(stderr);
channel.show(true);
getOutputChannel().appendLine(stderr);
getOutputChannel().show(true);
}
let result: vscode.Task[] = [];
if (stdout) {
@ -166,11 +173,15 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
}
return result;
} catch (err) {
let channel = getOutputChannel();
if (err.stderr) {
channel.appendLine(err.stderr);
channel.show(true);
}
if (err.stdout) {
channel.appendLine(err.stdout);
}
channel.appendLine(localize('execFailed', 'Auto detecting Grunt failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
channel.show(true);
return emptyTasks;
}
}

View file

@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
});
}
let _channel: vscode.OutputChannel;
function getOutputChannel(): vscode.OutputChannel {
if (!_channel) {
_channel = vscode.window.createOutputChannel('Gulp Auto Detection');
}
return _channel;
}
async function getGulpTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
@ -98,12 +106,11 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
}
let commandLine = `${gulpCommand} --tasks-simple --no-color`;
let channel = vscode.window.createOutputChannel('tasks');
try {
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
if (stderr) {
channel.appendLine(stderr);
channel.show(true);
if (stderr && stderr.length > 0) {
getOutputChannel().appendLine(stderr);
getOutputChannel().show(true);
}
let result: vscode.Task[] = [];
if (stdout) {
@ -137,10 +144,15 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
}
return result;
} catch (err) {
let channel = getOutputChannel();
if (err.stderr) {
channel.appendLine(err.stderr);
}
if (err.stdout) {
channel.appendLine(err.stdout);
}
channel.appendLine(localize('execFailed', 'Auto detecting gulp failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
channel.show(true);
return emptyTasks;
}
}

View file

@ -73,6 +73,14 @@ function exec(command: string, options: cp.ExecOptions): Promise<{ stdout: strin
});
}
let _channel: vscode.OutputChannel;
function getOutputChannel(): vscode.OutputChannel {
if (!_channel) {
_channel = vscode.window.createOutputChannel('Jake Auto Detection');
}
return _channel;
}
async function getJakeTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
@ -98,12 +106,11 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
}
let commandLine = `${jakeCommand} --tasks`;
let channel = vscode.window.createOutputChannel('tasks');
try {
let { stdout, stderr } = await exec(commandLine, { cwd: workspaceRoot });
if (stderr) {
channel.appendLine(stderr);
channel.show(true);
getOutputChannel().appendLine(stderr);
getOutputChannel().show(true);
}
let result: vscode.Task[] = [];
if (stdout) {
@ -142,10 +149,15 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
}
return result;
} catch (err) {
let channel = getOutputChannel();
if (err.stderr) {
channel.appendLine(err.stderr);
}
if (err.stdout) {
channel.appendLine(err.stdout);
}
channel.appendLine(localize('execFailed', 'Auto detecting Jake failed with error: {0}', err.error ? err.error.toString() : 'unknown'));
channel.show(true);
return emptyTasks;
}
}