-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathtaskProvider.ts
More file actions
148 lines (137 loc) · 3.9 KB
/
taskProvider.ts
File metadata and controls
148 lines (137 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import * as vscode from "vscode";
import { getProjectDir } from "./project";
export class TaskProvider implements vscode.TaskProvider {
// Referenced in package.json::taskDefinitions
static TaskType = "mix";
public provideTasks(): vscode.Task[] {
const wsFolders = vscode.workspace.workspaceFolders;
if (!wsFolders || wsFolders.length === 0) {
vscode.window.showErrorMessage("no workspace open...");
return [];
}
// TODO make sure that problem matchers are working
// TODO better handle multi root workspaces
const tasks = [];
const taskSpecs = [
{
name: "Run tests",
command: "mix test",
group: vscode.TaskGroup.Test,
matchers: ["$mixCompileError", "$mixCompileWarning", "$mixTestFailure"],
},
{
name: "Run tests with coverage",
command: "mix test.coverage",
group: vscode.TaskGroup.Test,
matchers: ["$mixCompileError", "$mixCompileWarning", "$mixTestFailure"],
},
{
name: "Run test at cursor",
command: "mix test ${relativeFile}:${lineNumber}",
group: vscode.TaskGroup.Test,
matchers: ["$mixCompileError", "$mixCompileWarning", "$mixTestFailure"],
},
{
name: "Run tests in current file",
command: "mix test ${relativeFile}",
group: vscode.TaskGroup.Test,
matchers: ["$mixCompileError", "$mixCompileWarning", "$mixTestFailure"],
},
{
name: "Build",
command: "mix compile",
group: vscode.TaskGroup.Build,
matchers: ["$mixCompileError", "$mixCompileWarning"],
},
{
name: "Build dependencies",
command: "mix deps.compile",
group: vscode.TaskGroup.Build,
matchers: ["$mixCompileError", "$mixCompileWarning"],
},
{
name: "Clean project",
command: "mix clean",
group: vscode.TaskGroup.Clean,
},
{
name: "Clean project and deps",
command: "mix clean --deps",
group: vscode.TaskGroup.Clean,
},
{
name: "Print app tree",
command: "mix app.tree",
},
{
name: "List deps",
command: "mix deps",
},
{
name: "Clean all deps",
command: "mix deps.clean --all",
group: vscode.TaskGroup.Clean,
},
{
name: "Clean all unused deps",
command: "mix deps.clean --unlock --unused",
group: vscode.TaskGroup.Clean,
},
{
name: "Get deps",
command: "mix deps.get",
},
{
name: "Update all deps",
command: "mix deps.update --all",
},
{
name: "Format",
command: "mix format",
},
{
name: "Run",
command: "mix run",
},
{
name: "Run no halt",
command: "mix run --no-halt",
},
{
name: "Generates sample files for releases",
command: "mix release.init",
},
{
name: "Trace file dependencies",
command: "mix xref trace ${relativeFile}",
},
{
name: "Print file dependency graph",
command: "mix xref graph",
},
];
for (const folder of wsFolders) {
const projectDir = getProjectDir(folder);
for (const spec of taskSpecs) {
const task = new vscode.Task(
{ type: TaskProvider.TaskType, task: spec.name },
folder,
spec.name,
TaskProvider.TaskType,
new vscode.ShellExecution(spec.command, { cwd: projectDir }),
spec.matchers,
);
if (spec.group) {
task.group = spec.group;
}
tasks.push(task);
}
}
return tasks;
}
public resolveTask(_task: vscode.Task): vscode.Task | undefined {
// This method can be implemented to improve performance.
// See: https://code.visualstudio.com/api/extension-guides/task-provider
return undefined;
}
}