Make tthe source attribute mandantory for tasks defined in extensions

This commit is contained in:
Dirk Baeumer 2017-06-25 22:44:23 +02:00
parent 3f36a65d73
commit cf594ad817
7 changed files with 23 additions and 19 deletions

View file

@ -169,16 +169,17 @@ async function getGruntTasks(): Promise<vscode.Task[]> {
let regExp = /^\s*(\S.*\S) \S/g; let regExp = /^\s*(\S.*\S) \S/g;
let matches = regExp.exec(line); let matches = regExp.exec(line);
if (matches && matches.length === 2) { if (matches && matches.length === 2) {
let taskName = matches[1]; let name = matches[1];
let kind: GruntTaskKind = { let kind: GruntTaskKind = {
type: 'grunt', type: 'grunt',
task: taskName task: name
}; };
let task = taskName.indexOf(' ') === -1 let source = 'grunt';
? new vscode.Task(kind, taskName, new vscode.ShellExecution(`${command} ${taskName}`)) let task = name.indexOf(' ') === -1
: new vscode.Task(kind, taskName, new vscode.ShellExecution(`${command} "${taskName}"`)); ? new vscode.Task(kind, name, source, new vscode.ShellExecution(`${command} ${name}`))
: new vscode.Task(kind, name, source, new vscode.ShellExecution(`${command} "${name}"`));
result.push(task); result.push(task);
let lowerCaseTaskName = taskName.toLowerCase(); let lowerCaseTaskName = name.toLowerCase();
if (isBuildTask(lowerCaseTaskName)) { if (isBuildTask(lowerCaseTaskName)) {
task.group = vscode.TaskGroup.Build; task.group = vscode.TaskGroup.Build;
} else if (isTestTask(lowerCaseTaskName)) { } else if (isTestTask(lowerCaseTaskName)) {

View file

@ -151,7 +151,7 @@ async function getGulpTasks(): Promise<vscode.Task[]> {
type: 'gulp', type: 'gulp',
task: line task: line
}; };
let task = new vscode.Task(kind, line, new vscode.ShellExecution(`${gulpCommand} ${line}`)); let task = new vscode.Task(kind, line, 'gulp', new vscode.ShellExecution(`${gulpCommand} ${line}`));
result.push(task); result.push(task);
let lowerCaseLine = line.toLowerCase(); let lowerCaseLine = line.toLowerCase();
if (isBuildTask(lowerCaseLine)) { if (isBuildTask(lowerCaseLine)) {

View file

@ -155,7 +155,7 @@ async function getJakeTasks(): Promise<vscode.Task[]> {
type: 'jake', type: 'jake',
task: taskName task: taskName
}; };
let task = new vscode.Task(kind, taskName, new vscode.ShellExecution(`${jakeCommand} ${taskName}`)); let task = new vscode.Task(kind, taskName, 'jake', new vscode.ShellExecution(`${jakeCommand} ${taskName}`));
result.push(task); result.push(task);
let lowerCaseLine = line.toLowerCase(); let lowerCaseLine = line.toLowerCase();
if (isBuildTask(lowerCaseLine)) { if (isBuildTask(lowerCaseLine)) {

View file

@ -113,7 +113,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
type: 'npm', type: 'npm',
script: each script: each
}; };
const task = new vscode.Task(kind, `run ${each}`, new vscode.ShellExecution(`npm run ${each}`)); const task = new vscode.Task(kind, `run ${each}`, 'npm', new vscode.ShellExecution(`npm run ${each}`));
const lowerCaseTaskName = each.toLowerCase(); const lowerCaseTaskName = each.toLowerCase();
if (isBuildTask(lowerCaseTaskName)) { if (isBuildTask(lowerCaseTaskName)) {
task.group = vscode.TaskGroup.Build; task.group = vscode.TaskGroup.Build;
@ -123,7 +123,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
result.push(task); result.push(task);
}); });
// add some 'well known' npm tasks // add some 'well known' npm tasks
result.push(new vscode.Task({ type: 'npm', script: 'install' } as NpmTaskKind, `install`, new vscode.ShellExecution(`npm install`))); result.push(new vscode.Task({ type: 'npm', script: 'install' } as NpmTaskKind, `install`, 'npm', new vscode.ShellExecution(`npm install`)));
return Promise.resolve(result); return Promise.resolve(result);
} catch (e) { } catch (e) {
return Promise.resolve(emptyTasks); return Promise.resolve(emptyTasks);

View file

@ -54,8 +54,7 @@ class TscTaskProvider implements vscode.TaskProvider {
return projects.map(configFile => { return projects.map(configFile => {
const configFileName = path.relative(rootPath, configFile); const configFileName = path.relative(rootPath, configFile);
const identifier: TypeScriptTaskIdentifier = { type: 'typescript', tsconfig: configFileName }; const identifier: TypeScriptTaskIdentifier = { type: 'typescript', tsconfig: configFileName };
const buildTask = new vscode.Task(identifier, `build ${configFileName}`, new vscode.ShellExecution(`${command} -p "${configFile}"`), '$tsc'); const buildTask = new vscode.Task(identifier, `build ${configFileName}`, 'tsc', new vscode.ShellExecution(`${command} -p "${configFile}"`), '$tsc');
buildTask.source = 'tsc';
buildTask.group = vscode.TaskGroup.Build; buildTask.group = vscode.TaskGroup.Build;
return buildTask; return buildTask;
}); });

View file

@ -250,29 +250,32 @@ declare module 'vscode' {
* *
* @param kind The task kind as defined in the 'taskKinds' extension point. * @param kind The task kind as defined in the 'taskKinds' extension point.
* @param name The task's name. Is presented in the user interface. * @param name The task's name. Is presented in the user interface.
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
*/ */
constructor(kind: TaskKind, name: string); constructor(kind: TaskKind, name: string, source: string);
/** /**
* Creates a new task. * Creates a new task.
* *
* @param kind The task kind as defined in the 'taskKinds' extension point. * @param kind The task kind as defined in the 'taskKinds' extension point.
* @param name The task's name. Is presented in the user interface. * @param name The task's name. Is presented in the user interface.
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
* @param execution The process or shell execution. * @param execution The process or shell execution.
*/ */
constructor(kind: TaskKind, name: string, execution: ProcessExecution | ShellExecution); constructor(kind: TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution);
/** /**
* Creates a new task. * Creates a new task.
* *
* @param kind The task kind as defined in the 'taskKinds' extension point. * @param kind The task kind as defined in the 'taskKinds' extension point.
* @param name The task's name. Is presented in the user interface. * @param name The task's name. Is presented in the user interface.
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
* @param execution The process or shell execution. * @param execution The process or shell execution.
* @param problemMatchers the names of problem matchers to use, like '$tsc' * @param problemMatchers the names of problem matchers to use, like '$tsc'
* or '$eslint'. Problem matchers can be contributed by an extension using * or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point. * the `problemMatchers` extension point.
*/ */
constructor(kind: TaskKind, name: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]); constructor(kind: TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
/** /**
* The task's kind. * The task's kind.

View file

@ -1164,13 +1164,14 @@ export class Task implements vscode.Task {
private _presentationOptions: vscode.TaskPresentationOptions; private _presentationOptions: vscode.TaskPresentationOptions;
constructor(kind: vscode.TaskKind, name: string); constructor(kind: vscode.TaskKind, name: string, source: string);
constructor(kind: vscode.TaskKind, name: string, execution: ProcessExecution | ShellExecution); constructor(kind: vscode.TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution);
constructor(kind: vscode.TaskKind, name: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]); constructor(kind: vscode.TaskKind, name: string, source: string, execution: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
constructor(kind: vscode.TaskKind, name: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) { constructor(kind: vscode.TaskKind, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) {
this.kind = kind; this.kind = kind;
this.name = name; this.name = name;
this.source = source;
this.execution = execution; this.execution = execution;
if (typeof problemMatchers === 'string') { if (typeof problemMatchers === 'string') {
this._problemMatchers = [problemMatchers]; this._problemMatchers = [problemMatchers];