8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- import { Disposable , ShellExecution , ShellExecutionOptions , Task , TaskDefinition , TaskGroup , TaskPanelKind , TaskPresentationOptions , TaskProvider , TaskRevealKind , WorkspaceFolder , workspace , tasks } from 'vscode' ;
11
+ import { Disposable , ShellExecution , ShellExecutionOptions , Task , TaskDefinition , TaskGroup , TaskPanelKind , TaskPresentationOptions , TaskProvider , TaskRevealKind , WorkspaceFolder , workspace , tasks , TaskExecution } from 'vscode' ;
12
12
13
13
export function activateTaskProvider ( target : WorkspaceFolder ) : Disposable {
14
14
const provider : TaskProvider = {
@@ -28,8 +28,7 @@ export function activateTaskProvider(target: WorkspaceFolder): Disposable {
28
28
}
29
29
30
30
interface CargoTaskDefinition extends TaskDefinition {
31
- // FIXME: By the document, we should add the `taskDefinitions` section to our package.json and use the value of it.
32
- type : 'shell' ;
31
+ type : 'cargo' ;
33
32
label : string ;
34
33
command : string ;
35
34
args : Array < string > ;
@@ -89,7 +88,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
89
88
{
90
89
definition : {
91
90
label : 'cargo build' ,
92
- type : 'shell ' ,
91
+ type : 'cargo ' ,
93
92
command : 'cargo' ,
94
93
args : [
95
94
'build'
@@ -102,7 +101,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
102
101
{
103
102
definition : {
104
103
label : 'cargo check' ,
105
- type : 'shell ' ,
104
+ type : 'cargo ' ,
106
105
command : 'cargo' ,
107
106
args : [
108
107
'check'
@@ -115,7 +114,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
115
114
{
116
115
definition : {
117
116
label : 'cargo run' ,
118
- type : 'shell ' ,
117
+ type : 'cargo ' ,
119
118
command : 'cargo' ,
120
119
args : [
121
120
'run'
@@ -127,7 +126,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
127
126
{
128
127
definition : {
129
128
label : 'cargo test' ,
130
- type : 'shell ' ,
129
+ type : 'cargo ' ,
131
130
command : 'cargo' ,
132
131
args : [
133
132
'test'
@@ -140,7 +139,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
140
139
{
141
140
definition : {
142
141
label : 'cargo bench' ,
143
- type : 'shell ' ,
142
+ type : 'cargo ' ,
144
143
command : 'cargo' ,
145
144
args : [
146
145
'+nightly' ,
@@ -154,7 +153,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
154
153
{
155
154
definition : {
156
155
label : 'cargo clean' ,
157
- type : 'shell ' ,
156
+ type : 'cargo ' ,
158
157
command : 'cargo' ,
159
158
args : [
160
159
'clean'
@@ -174,11 +173,11 @@ export interface Cmd {
174
173
env : { [ key : string ] : string } ;
175
174
}
176
175
177
- export function runCommand ( folder : WorkspaceFolder , cmd : Cmd ) {
176
+ export function runCommand ( folder : WorkspaceFolder , cmd : Cmd ) : Thenable < TaskExecution > {
178
177
const config : TaskConfigItem = {
179
178
definition : {
180
179
label : 'run Cargo command' ,
181
- type : 'shell ' ,
180
+ type : 'cargo ' ,
182
181
command : cmd . binary ,
183
182
args : cmd . args ,
184
183
env : cmd . env ,
@@ -191,5 +190,5 @@ export function runCommand(folder: WorkspaceFolder, cmd: Cmd) {
191
190
} ,
192
191
} ;
193
192
const task = createTask ( config , folder ) ;
194
- tasks . executeTask ( task ) ;
193
+ return tasks . executeTask ( task ) ;
195
194
}
0 commit comments