Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/tasks.ts')
-rw-r--r--editors/code/src/tasks.ts40
1 files changed, 25 insertions, 15 deletions
diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts
index 99edd9ae9d..8aa6bcee19 100644
--- a/editors/code/src/tasks.ts
+++ b/editors/code/src/tasks.ts
@@ -1,12 +1,12 @@
-import * as vscode from 'vscode';
+import * as vscode from "vscode";
import * as toolchain from "./toolchain";
-import { Config } from './config';
-import { log } from './util';
+import { Config } from "./config";
+import { log } from "./util";
// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
// our configuration should be compatible with it so use the same key.
-export const TASK_TYPE = 'cargo';
-export const TASK_SOURCE = 'rust';
+export const TASK_TYPE = "cargo";
+export const TASK_SOURCE = "rust";
export interface CargoTaskDefinition extends vscode.TaskDefinition {
command?: string;
@@ -30,17 +30,23 @@ class CargoTaskProvider implements vscode.TaskProvider {
// tasks.json - only tweaked.
const defs = [
- { command: 'build', group: vscode.TaskGroup.Build },
- { command: 'check', group: vscode.TaskGroup.Build },
- { command: 'test', group: vscode.TaskGroup.Test },
- { command: 'clean', group: vscode.TaskGroup.Clean },
- { command: 'run', group: undefined },
+ { command: "build", group: vscode.TaskGroup.Build },
+ { command: "check", group: vscode.TaskGroup.Build },
+ { command: "test", group: vscode.TaskGroup.Test },
+ { command: "clean", group: vscode.TaskGroup.Clean },
+ { command: "run", group: undefined },
];
const tasks: vscode.Task[] = [];
for (const workspaceTarget of vscode.workspace.workspaceFolders || []) {
for (const def of defs) {
- const vscodeTask = await buildCargoTask(workspaceTarget, { type: TASK_TYPE, command: def.command }, `cargo ${def.command}`, [def.command], this.config.cargoRunner);
+ const vscodeTask = await buildCargoTask(
+ workspaceTarget,
+ { type: TASK_TYPE, command: def.command },
+ `cargo ${def.command}`,
+ [def.command],
+ this.config.cargoRunner
+ );
vscodeTask.group = def.group;
tasks.push(vscodeTask);
}
@@ -58,7 +64,13 @@ class CargoTaskProvider implements vscode.TaskProvider {
if (definition.type === TASK_TYPE && definition.command) {
const args = [definition.command].concat(definition.args ?? []);
- return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
+ return await buildCargoTask(
+ task.scope,
+ definition,
+ task.name,
+ args,
+ this.config.cargoRunner
+ );
}
return undefined;
@@ -73,7 +85,6 @@ export async function buildCargoTask(
customRunner?: string,
throwOnError: boolean = false
): Promise<vscode.Task> {
-
let exec: vscode.ProcessExecution | vscode.ShellExecution | undefined = undefined;
if (customRunner) {
@@ -90,7 +101,6 @@ export async function buildCargoTask(
}
}
// fallback to default processing
-
} catch (e) {
if (throwOnError) throw `Cargo runner '${customRunner}' failed! ${e}`;
// fallback to default processing
@@ -117,7 +127,7 @@ export async function buildCargoTask(
name,
TASK_SOURCE,
exec,
- ['$rustc']
+ ["$rustc"]
);
}