Skip to content

Commit cf594ad

Browse files
committed
Make tthe source attribute mandantory for tasks defined in extensions
1 parent 3f36a65 commit cf594ad

7 files changed

Lines changed: 23 additions & 19 deletions

File tree

extensions/grunt/src/main.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,17 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
169169
let regExp = /^\s*(\S.*\S) \S/g;
170170
let matches = regExp.exec(line);
171171
if (matches && matches.length === 2) {
172-
let taskName = matches[1];
172+
let name = matches[1];
173173
let kind: GruntTaskKind = {
174174
type: 'grunt',
175-
task: taskName
175+
task: name
176176
};
177-
let task = taskName.indexOf(' ') === -1
178-
? new vscode.Task(kind, taskName, new vscode.ShellExecution(`${command} ${taskName}`))
179-
: new vscode.Task(kind, taskName, new vscode.ShellExecution(`${command} "${taskName}"`));
177+
let source = 'grunt';
178+
let task = name.indexOf(' ') === -1
179+
? new vscode.Task(kind, name, source, new vscode.ShellExecution(`${command} ${name}`))
180+
: new vscode.Task(kind, name, source, new vscode.ShellExecution(`${command} "${name}"`));
180181
result.push(task);
181-
let lowerCaseTaskName = taskName.toLowerCase();
182+
let lowerCaseTaskName = name.toLowerCase();
182183
if (isBuildTask(lowerCaseTaskName)) {
183184
task.group = vscode.TaskGroup.Build;
184185
} else if (isTestTask(lowerCaseTaskName)) {

extensions/gulp/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
151151
type: 'gulp',
152152
task: line
153153
};
154-
let task = new vscode.Task(kind, line, new vscode.ShellExecution(`${gulpCommand} ${line}`));
154+
let task = new vscode.Task(kind, line, 'gulp', new vscode.ShellExecution(`${gulpCommand} ${line}`));
155155
result.push(task);
156156
let lowerCaseLine = line.toLowerCase();
157157
if (isBuildTask(lowerCaseLine)) {

extensions/jake/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
155155
type: 'jake',
156156
task: taskName
157157
};
158-
let task = new vscode.Task(kind, taskName, new vscode.ShellExecution(`${jakeCommand} ${taskName}`));
158+
let task = new vscode.Task(kind, taskName, 'jake', new vscode.ShellExecution(`${jakeCommand} ${taskName}`));
159159
result.push(task);
160160
let lowerCaseLine = line.toLowerCase();
161161
if (isBuildTask(lowerCaseLine)) {

extensions/npm/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
113113
type: 'npm',
114114
script: each
115115
};
116-
const task = new vscode.Task(kind, `run ${each}`, new vscode.ShellExecution(`npm run ${each}`));
116+
const task = new vscode.Task(kind, `run ${each}`, 'npm', new vscode.ShellExecution(`npm run ${each}`));
117117
const lowerCaseTaskName = each.toLowerCase();
118118
if (isBuildTask(lowerCaseTaskName)) {
119119
task.group = vscode.TaskGroup.Build;
@@ -123,7 +123,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
123123
result.push(task);
124124
});
125125
// add some 'well known' npm tasks
126-
result.push(new vscode.Task({ type: 'npm', script: 'install' } as NpmTaskKind, `install`, new vscode.ShellExecution(`npm install`)));
126+
result.push(new vscode.Task({ type: 'npm', script: 'install' } as NpmTaskKind, `install`, 'npm', new vscode.ShellExecution(`npm install`)));
127127
return Promise.resolve(result);
128128
} catch (e) {
129129
return Promise.resolve(emptyTasks);

extensions/typescript/src/features/taskProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class TscTaskProvider implements vscode.TaskProvider {
5454
return projects.map(configFile => {
5555
const configFileName = path.relative(rootPath, configFile);
5656
const identifier: TypeScriptTaskIdentifier = { type: 'typescript', tsconfig: configFileName };
57-
const buildTask = new vscode.Task(identifier, `build ${configFileName}`, new vscode.ShellExecution(`${command} -p "${configFile}"`), '$tsc');
58-
buildTask.source = 'tsc';
57+
const buildTask = new vscode.Task(identifier, `build ${configFileName}`, 'tsc', new vscode.ShellExecution(`${command} -p "${configFile}"`), '$tsc');
5958
buildTask.group = vscode.TaskGroup.Build;
6059
return buildTask;
6160
});

src/vs/vscode.proposed.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,29 +250,32 @@ declare module 'vscode' {
250250
*
251251
* @param kind The task kind as defined in the 'taskKinds' extension point.
252252
* @param name The task's name. Is presented in the user interface.
253+
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
253254
*/
254-
constructor(kind: TaskKind, name: string);
255+
constructor(kind: TaskKind, name: string, source: string);
255256

256257
/**
257258
* Creates a new task.
258259
*
259260
* @param kind The task kind as defined in the 'taskKinds' extension point.
260261
* @param name The task's name. Is presented in the user interface.
262+
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
261263
* @param execution The process or shell execution.
262264
*/
263-
constructor(kind: TaskKind, name: string, execution: ProcessExecution | ShellExecution);
265+
constructor(kind: TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution);
264266

265267
/**
266268
* Creates a new task.
267269
*
268270
* @param kind The task kind as defined in the 'taskKinds' extension point.
269271
* @param name The task's name. Is presented in the user interface.
272+
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
270273
* @param execution The process or shell execution.
271274
* @param problemMatchers the names of problem matchers to use, like '$tsc'
272275
* or '$eslint'. Problem matchers can be contributed by an extension using
273276
* the `problemMatchers` extension point.
274277
*/
275-
constructor(kind: TaskKind, name: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
278+
constructor(kind: TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
276279

277280
/**
278281
* The task's kind.

src/vs/workbench/api/node/extHostTypes.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,13 +1164,14 @@ export class Task implements vscode.Task {
11641164
private _presentationOptions: vscode.TaskPresentationOptions;
11651165

11661166

1167-
constructor(kind: vscode.TaskKind, name: string);
1168-
constructor(kind: vscode.TaskKind, name: string, execution: ProcessExecution | ShellExecution);
1169-
constructor(kind: vscode.TaskKind, name: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
1167+
constructor(kind: vscode.TaskKind, name: string, source: string);
1168+
constructor(kind: vscode.TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution);
1169+
constructor(kind: vscode.TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
11701170

1171-
constructor(kind: vscode.TaskKind, name: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) {
1171+
constructor(kind: vscode.TaskKind, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) {
11721172
this.kind = kind;
11731173
this.name = name;
1174+
this.source = source;
11741175
this.execution = execution;
11751176
if (typeof problemMatchers === 'string') {
11761177
this._problemMatchers = [problemMatchers];

0 commit comments

Comments
 (0)