Skip to content

Commit

Permalink
Ensure cwd is recorded against tasks for monorepo projects
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTup committed Mar 1, 2022
1 parent 3fa9e24 commit 17f353c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,9 @@
"command": {
"type": "string"
},
"cwd": {
"type": "string"
},
"args": {
"type": "array",
"items": {
Expand Down
9 changes: 6 additions & 3 deletions src/extension/dart/dart_task_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export abstract class BaseTaskProvider implements vs.TaskProvider {

public async resolveTask(task: DartTask, token?: vs.CancellationToken): Promise<vs.Task> {
const scope: any = task.scope;
const cwd = task.definition.cwd ?? ("uri" in scope ? fsPath((scope as vs.WorkspaceFolder).uri) : undefined);
const workspaceFolderPath = "uri" in scope ? fsPath((scope as vs.WorkspaceFolder).uri) : undefined;
const definitionCwd = task.definition.cwd;
const cwd = workspaceFolderPath && definitionCwd ? path.join(workspaceFolderPath, definitionCwd) : task.definition.cwd ?? workspaceFolderPath;

const definition = task.definition;

Expand Down Expand Up @@ -110,15 +112,16 @@ export abstract class BaseTaskProvider implements vs.TaskProvider {
private createTaskStub(workspaceFolder: vs.WorkspaceFolder, projectFolder: vs.Uri, command: string, args: string[]): vs.Task {
const workspaceFolderPath = fsPath(workspaceFolder.uri);
const projectPath = fsPath(projectFolder);
const relativePath = path.relative(workspaceFolderPath, projectPath);
const task = new vs.Task(
{ type: this.type, cwd: fsPath(projectFolder), command, args } as DartTaskDefinition,
{ type: this.type, cwd: relativePath, command, args } as DartTaskDefinition,
workspaceFolder,
[command, ...args].join(" "),
this.type,
undefined,
undefined
);
task.detail = path.relative(workspaceFolderPath, projectPath);
task.detail = relativePath;
return task;
}

Expand Down

0 comments on commit 17f353c

Please sign in to comment.