mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
More loose build and test task detection
This commit is contained in:
parent
8e0d8cfc1e
commit
2903fc5ee5
|
@ -89,6 +89,26 @@ interface GruntTaskKind extends vscode.TaskKind {
|
|||
file?: string;
|
||||
}
|
||||
|
||||
const buildNames: string[] = ['build', 'compile', 'watch'];
|
||||
function isBuildTask(name: string): boolean {
|
||||
for (let buildName of buildNames) {
|
||||
if (name.indexOf(buildName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const testNames: string[] = ['test'];
|
||||
function isTestTask(name: string): boolean {
|
||||
for (let testName of testNames) {
|
||||
if (name.indexOf(testName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getGruntTasks(): Promise<vscode.Task[]> {
|
||||
let workspaceRoot = vscode.workspace.rootPath;
|
||||
let emptyTasks: vscode.Task[] = [];
|
||||
|
@ -119,9 +139,6 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
|
|||
}
|
||||
let result: vscode.Task[] = [];
|
||||
if (stdout) {
|
||||
let buildTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
let testTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
|
||||
// grunt lists tasks as follows (description is wrapped into a new line if too long):
|
||||
// ...
|
||||
// Available tasks
|
||||
|
@ -162,25 +179,15 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
|
|||
: new vscode.Task(kind, taskName, new vscode.ShellExecution(`${command} "${taskName}"`));
|
||||
result.push(task);
|
||||
let lowerCaseTaskName = taskName.toLowerCase();
|
||||
if (lowerCaseTaskName === 'build') {
|
||||
buildTask = { task, rank: 2 };
|
||||
} else if (lowerCaseTaskName.indexOf('build') !== -1 && buildTask.rank < 1) {
|
||||
buildTask = { task, rank: 1 };
|
||||
} else if (lowerCaseTaskName === 'test') {
|
||||
testTask = { task, rank: 2 };
|
||||
} else if (lowerCaseTaskName.indexOf('test') !== -1 && testTask.rank < 1) {
|
||||
testTask = { task, rank: 1 };
|
||||
if (isBuildTask(lowerCaseTaskName)) {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
} else if (isTestTask(lowerCaseTaskName)) {
|
||||
task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buildTask.task) {
|
||||
buildTask.task.group = vscode.TaskGroup.Build;
|
||||
}
|
||||
if (testTask.task) {
|
||||
testTask.task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
|
|
|
@ -89,6 +89,26 @@ interface GulpTaskKind extends vscode.TaskKind {
|
|||
file?: string;
|
||||
}
|
||||
|
||||
const buildNames: string[] = ['build', 'compile', 'watch'];
|
||||
function isBuildTask(name: string): boolean {
|
||||
for (let buildName of buildNames) {
|
||||
if (name.indexOf(buildName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const testNames: string[] = ['test'];
|
||||
function isTestTask(name: string): boolean {
|
||||
for (let testName of testNames) {
|
||||
if (name.indexOf(testName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getGulpTasks(): Promise<vscode.Task[]> {
|
||||
let workspaceRoot = vscode.workspace.rootPath;
|
||||
let emptyTasks: vscode.Task[] = [];
|
||||
|
@ -122,8 +142,6 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
|
|||
}
|
||||
let result: vscode.Task[] = [];
|
||||
if (stdout) {
|
||||
let buildTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
let testTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
let lines = stdout.split(/\r{0,1}\n/);
|
||||
for (let line of lines) {
|
||||
if (line.length === 0) {
|
||||
|
@ -136,22 +154,12 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
|
|||
let task = new vscode.Task(kind, line, new vscode.ShellExecution(`${gulpCommand} ${line}`));
|
||||
result.push(task);
|
||||
let lowerCaseLine = line.toLowerCase();
|
||||
if (lowerCaseLine === 'build') {
|
||||
buildTask = { task, rank: 2 };
|
||||
} else if (lowerCaseLine.indexOf('build') !== -1 && buildTask.rank < 1) {
|
||||
buildTask = { task, rank: 1 };
|
||||
} else if (lowerCaseLine === 'test') {
|
||||
testTask = { task, rank: 2 };
|
||||
} else if (lowerCaseLine.indexOf('test') !== -1 && testTask.rank < 1) {
|
||||
testTask = { task, rank: 1 };
|
||||
if (isBuildTask(lowerCaseLine)) {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
} else if (isTestTask(lowerCaseLine)) {
|
||||
task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
if (buildTask.task) {
|
||||
buildTask.task.group = vscode.TaskGroup.Build;
|
||||
}
|
||||
if (testTask.task) {
|
||||
testTask.task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
|
|
|
@ -89,6 +89,26 @@ interface JakeTaskKind extends vscode.TaskKind {
|
|||
file?: string;
|
||||
}
|
||||
|
||||
const buildNames: string[] = ['build', 'compile', 'watch'];
|
||||
function isBuildTask(name: string): boolean {
|
||||
for (let buildName of buildNames) {
|
||||
if (name.indexOf(buildName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const testNames: string[] = ['test'];
|
||||
function isTestTask(name: string): boolean {
|
||||
for (let testName of testNames) {
|
||||
if (name.indexOf(testName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getJakeTasks(): Promise<vscode.Task[]> {
|
||||
let workspaceRoot = vscode.workspace.rootPath;
|
||||
let emptyTasks: vscode.Task[] = [];
|
||||
|
@ -122,8 +142,6 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
|
|||
}
|
||||
let result: vscode.Task[] = [];
|
||||
if (stdout) {
|
||||
let buildTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
let testTask: { task: vscode.Task | undefined, rank: number } = { task: undefined, rank: 0 };
|
||||
let lines = stdout.split(/\r{0,1}\n/);
|
||||
for (let line of lines) {
|
||||
if (line.length === 0) {
|
||||
|
@ -140,23 +158,13 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
|
|||
let task = new vscode.Task(kind, taskName, new vscode.ShellExecution(`${jakeCommand} ${taskName}`));
|
||||
result.push(task);
|
||||
let lowerCaseLine = line.toLowerCase();
|
||||
if (lowerCaseLine === 'build') {
|
||||
buildTask = { task, rank: 2 };
|
||||
} else if (lowerCaseLine.indexOf('build') !== -1 && buildTask.rank < 1) {
|
||||
buildTask = { task, rank: 1 };
|
||||
} else if (lowerCaseLine === 'test') {
|
||||
testTask = { task, rank: 2 };
|
||||
} else if (lowerCaseLine.indexOf('test') !== -1 && testTask.rank < 1) {
|
||||
testTask = { task, rank: 1 };
|
||||
if (isBuildTask(lowerCaseLine)) {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
} else if (isTestTask(lowerCaseLine)) {
|
||||
task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buildTask.task) {
|
||||
buildTask.task.group = vscode.TaskGroup.Build;
|
||||
}
|
||||
if (testTask.task) {
|
||||
testTask.task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
|
|
|
@ -67,6 +67,25 @@ interface NpmTaskKind extends vscode.TaskKind {
|
|||
file?: string;
|
||||
}
|
||||
|
||||
const buildNames: string[] = ['build', 'compile', 'watch'];
|
||||
function isBuildTask(name: string): boolean {
|
||||
for (let buildName of buildNames) {
|
||||
if (name.indexOf(buildName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const testNames: string[] = ['test'];
|
||||
function isTestTask(name: string): boolean {
|
||||
for (let testName of testNames) {
|
||||
if (name === testName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
||||
let workspaceRoot = vscode.workspace.rootPath;
|
||||
|
@ -96,9 +115,9 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
|||
};
|
||||
const task = new vscode.Task(kind, `run ${each}`, new vscode.ShellExecution(`npm run ${each}`));
|
||||
const lowerCaseTaskName = each.toLowerCase();
|
||||
if (lowerCaseTaskName === 'build') {
|
||||
if (isBuildTask(lowerCaseTaskName)) {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
} else if (lowerCaseTaskName === 'test') {
|
||||
} else if (isTestTask(lowerCaseTaskName)) {
|
||||
task.group = vscode.TaskGroup.Test;
|
||||
}
|
||||
result.push(task);
|
||||
|
|
Loading…
Reference in a new issue