Skip to content

Commit

Permalink
Configure plugin provided workspace tasks under a root folder
Browse files Browse the repository at this point in the history
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
  • Loading branch information
alvsan09 committed Mar 9, 2021
1 parent 14574ba commit 37ff92b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
TaskInfo,
TaskOutputPresentation,
TaskOutputProcessedEvent,
TaskScope,
TaskServer
} from '../common';
import { TaskWatcher } from '../common/task-watcher';
Expand Down Expand Up @@ -1105,7 +1106,20 @@ export class TaskService implements TaskConfigurationClient {
* @param task The task to configure
*/
async configure(token: number, task: TaskConfiguration): Promise<void> {
Object.assign(task, { label: this.taskNameResolver.resolve(task) });
const adaptedProperties: {label: string, _scope?: string} = {label: this.taskNameResolver.resolve(task)};

// Configure plugin provided tasks of workspace scope in the first root folder
// we identify provided workspace tasks by the presence of the "scope" property.
if (task.scope === TaskScope.Workspace) {
const firstWorkspaceFolder = (await this.workspaceService.roots)[0]?.resource.toString();
if (firstWorkspaceFolder === undefined) {
console.log('Unable to save configuration as no workspace root folder exist');
return;
}
adaptedProperties._scope = firstWorkspaceFolder;
}

Object.assign(task, adaptedProperties);
await this.taskConfigurations.configure(token, task);
}

Expand Down

0 comments on commit 37ff92b

Please sign in to comment.