Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Fix tasks on VSCode 1.25 #361

Merged
merged 1 commit into from
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@
}
]
},
"taskDefinitions": [
{
"type": "cargo",
"required": [
"command"
],
"properties": {
"label": {
"type": "string"
},
"command": {
"type": "string"
},
"args": {
"type": "array"
},
"env": {
"type": "object"
}
}
}
],
"problemMatchers": [
{
"name": "rustc",
Expand Down
23 changes: 11 additions & 12 deletions src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

import { Disposable, ShellExecution, ShellExecutionOptions, Task, TaskDefinition, TaskGroup, TaskPanelKind, TaskPresentationOptions, TaskProvider, TaskRevealKind, WorkspaceFolder, workspace, tasks } from 'vscode';
import { Disposable, ShellExecution, ShellExecutionOptions, Task, TaskDefinition, TaskGroup, TaskPanelKind, TaskPresentationOptions, TaskProvider, TaskRevealKind, WorkspaceFolder, workspace, tasks, TaskExecution } from 'vscode';

export function activateTaskProvider(target: WorkspaceFolder): Disposable {
const provider: TaskProvider = {
Expand All @@ -28,8 +28,7 @@ export function activateTaskProvider(target: WorkspaceFolder): Disposable {
}

interface CargoTaskDefinition extends TaskDefinition {
// FIXME: By the document, we should add the `taskDefinitions` section to our package.json and use the value of it.
type: 'shell';
type: 'cargo';
label: string;
command: string;
args: Array<string>;
Expand Down Expand Up @@ -89,7 +88,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo build',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'build'
Expand All @@ -102,7 +101,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo check',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'check'
Expand All @@ -115,7 +114,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo run',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'run'
Expand All @@ -127,7 +126,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo test',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'test'
Expand All @@ -140,7 +139,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo bench',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'+nightly',
Expand All @@ -154,7 +153,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
{
definition: {
label: 'cargo clean',
type: 'shell',
type: 'cargo',
command: 'cargo',
args: [
'clean'
Expand All @@ -174,11 +173,11 @@ export interface Cmd {
env: { [key: string]: string };
}

export function runCommand(folder: WorkspaceFolder, cmd: Cmd) {
export function runCommand(folder: WorkspaceFolder, cmd: Cmd): Thenable<TaskExecution> {
const config: TaskConfigItem = {
definition: {
label: 'run Cargo command',
type: 'shell',
type: 'cargo',
command: cmd.binary,
args: cmd.args,
env: cmd.env,
Expand All @@ -191,5 +190,5 @@ export function runCommand(folder: WorkspaceFolder, cmd: Cmd) {
},
};
const task = createTask(config, folder);
tasks.executeTask(task);
return tasks.executeTask(task);
}