Skip to content

Commit

Permalink
Implemented latest feedback from #28235
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Jun 21, 2017
1 parent b7afeff commit 756ec07
Show file tree
Hide file tree
Showing 21 changed files with 1,083 additions and 554 deletions.
73 changes: 30 additions & 43 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
{
"version": "0.1.0",
"windows": {
"command": ".\\node_modules\\.bin\\gulp"
},
"osx": {
"command": "./node_modules/.bin/gulp"
},
"linux": {
"command": "./node_modules/.bin/gulp"
},
"isShellCommand": true,
"version": "2.0.0",
"tasks": [
{
"taskName": "watch",
"args": [
"--no-color"
],
"isBuildCommand": true,
"customize": "vscode.npm.run watch",
"taskName": "Build VS Code",
"group": "build",
"isBackground": true,
"terminal": {
"reveal": "never"
},
"problemMatcher": {
"owner": "typescript",
"applyTo": "closedDocuments",
Expand All @@ -37,38 +28,34 @@
}
},
{
"taskName": "tslint",
"args": [],
"problemMatcher": {
"owner": "tslint",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"severity": "warning",
"pattern": {
"regexp": "(.*)\\[(\\d+),\\s(\\d+)\\]:\\s(.*)$", // (.*)\[(\d+), (\d+)\]: (.*)
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
"customize": "gulp.tslint",
"taskName": "Run tslint",
"problemMatcher": ["$tslint4"]
},
{
"taskName": "Run tests",
"type": "shell",
"command": "./scripts/test.sh",
"windows": {
"command": ".\\scripts\\test.bat"
},
"group": "test",
"terminal": {
"echo": true,
"reveal": "always"
}
},
{
"taskName": "test",
"args": [
"--no-color"
],
"showOutput": "always",
"isTestCommand": true
"taskName": "Run Dev",
"type": "shell",
"command": "./scripts/code.sh",
"windows": {
"command": ".\\scripts\\code.bat"
}
},
{
"taskName": "electron",
"args": [
"--no-color"
],
"showOutput": "never"
"customize": "gulp.electron",
"taskName": "Download electron"
}
]
}
18 changes: 17 additions & 1 deletion extensions/grunt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@
"description": "%config.grunt.autoDetect%"
}
}
}
},
"taskTypes": [
{
"taskType": "grunt",
"required": ["task"],
"properties": {
"task": {
"type": "string",
"description": "The Grunt task to customize"
},
"file": {
"type": "string",
"description": "The Grunt file that provides the task. Can be omitted."
}
}
}
]
}
}
14 changes: 11 additions & 3 deletions extensions/grunt/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ function getOutputChannel(): vscode.OutputChannel {
return _channel;
}

interface GruntTaskIdentifier extends vscode.TaskIdentifier {
task: string;
file?: string;
}

async function getGruntTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
Expand Down Expand Up @@ -145,10 +150,13 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
let matches = regExp.exec(line);
if (matches && matches.length === 2) {
let taskName = matches[1];
let identifier: GruntTaskIdentifier = {
type: 'grunt',
task: taskName
};
let task = taskName.indexOf(' ') === -1
? new vscode.ShellTask(taskName, `${command} ${taskName}`)
: new vscode.ShellTask(taskName, `${command} "${taskName}"`);
task.identifier = `grunt.${taskName}`;
? new vscode.ShellTask(identifier, taskName, `${command} ${taskName}`)
: new vscode.ShellTask(identifier, taskName, `${command} "${taskName}"`);
result.push(task);
let lowerCaseTaskName = taskName.toLowerCase();
if (lowerCaseTaskName === 'build') {
Expand Down
12 changes: 10 additions & 2 deletions extensions/gulp/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ function getOutputChannel(): vscode.OutputChannel {
return _channel;
}

interface GulpTaskIdentifier extends vscode.TaskIdentifier {
task: string;
file?: string;
}

async function getGulpTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
Expand Down Expand Up @@ -121,8 +126,11 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
if (line.length === 0) {
continue;
}
let task = new vscode.ShellTask(line, `${gulpCommand} ${line}`);
task.identifier = `gulp.${line}`;
let identifier: GulpTaskIdentifier = {
type: 'gulp',
task: line
};
let task = new vscode.ShellTask(identifier, line, `${gulpCommand} ${line}`);
result.push(task);
let lowerCaseLine = line.toLowerCase();
if (lowerCaseLine === 'build') {
Expand Down
18 changes: 17 additions & 1 deletion extensions/jake/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@
"description": "%config.jake.autoDetect%"
}
}
}
},
"taskTypes": [
{
"taskType": "jake",
"required": ["task"],
"properties": {
"task": {
"type": "string",
"description": "The Jake task to customize"
},
"file": {
"type": "string",
"description": "The Jake file that provides the task. Can be omitted."
}
}
}
]
}
}
12 changes: 10 additions & 2 deletions extensions/jake/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ function getOutputChannel(): vscode.OutputChannel {
return _channel;
}

interface JakeTaskIdentifier extends vscode.TaskIdentifier {
task: string;
file?: string;
}

async function getJakeTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
Expand Down Expand Up @@ -125,8 +130,11 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
let matches = regExp.exec(line);
if (matches && matches.length === 2) {
let taskName = matches[1];
let task = new vscode.ShellTask(taskName, `${jakeCommand} ${taskName}`);
task.identifier = `jake.${taskName}`;
let identifier: JakeTaskIdentifier = {
type: 'jake',
task: taskName
};
let task = new vscode.ShellTask(identifier, taskName, `${jakeCommand} ${taskName}`);
result.push(task);
let lowerCaseLine = line.toLowerCase();
if (lowerCaseLine === 'build') {
Expand Down
14 changes: 12 additions & 2 deletions extensions/npm/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ async function readFile(file: string): Promise<string> {
});
}

interface NpmTaskIdentifier extends vscode.TaskIdentifier {
script: string;
file?: string;
}


async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
let workspaceRoot = vscode.workspace.rootPath;
let emptyTasks: vscode.Task[] = [];
Expand All @@ -81,7 +87,11 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {

const result: vscode.Task[] = [];
Object.keys(json.scripts).forEach(each => {
const task = new vscode.ShellTask(`run ${each}`, `npm run ${each}`);
const identifier: NpmTaskIdentifier = {
type: 'npm',
script: each
};
const task = new vscode.ShellTask(identifier, `run ${each}`, `npm run ${each}`);
const lowerCaseTaskName = each.toLowerCase();
if (lowerCaseTaskName === 'build') {
task.group = vscode.TaskGroup.Build;
Expand All @@ -91,7 +101,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
result.push(task);
});
// add some 'well known' npm tasks
result.push(new vscode.ShellTask(`install`, `npm install`));
result.push(new vscode.ShellTask({ type: 'npm', script: 'install' } as NpmTaskIdentifier, `install`, `npm install`));
return Promise.resolve(result);
} catch (e) {
return Promise.resolve(emptyTasks);
Expand Down
8 changes: 7 additions & 1 deletion extensions/typescript/src/features/taskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const exists = (file: string): Promise<boolean> =>
});
});


interface TypeScriptTaskIdentifier extends vscode.TaskIdentifier {
configFile: string;
}

/**
* Provides tasks for building `tsconfig.json` files in a project.
*/
Expand Down Expand Up @@ -48,7 +53,8 @@ class TscTaskProvider implements vscode.TaskProvider {

return projects.map(configFile => {
const configFileName = path.relative(rootPath, configFile);
const buildTask = new vscode.ShellTask(`build ${configFileName}`, `${command} -p "${configFile}"`, '$tsc');
const identifier: TypeScriptTaskIdentifier = { type: 'typescript', configFile: configFileName };
const buildTask = new vscode.ShellTask(identifier, `build ${configFileName}`, `${command} -p "${configFile}"`, '$tsc');
buildTask.source = 'tsc';
buildTask.group = vscode.TaskGroup.Build;
return buildTask;
Expand Down
Loading

0 comments on commit 756ec07

Please sign in to comment.