-
Notifications
You must be signed in to change notification settings - Fork 10
/
rustup.ts
23 lines (19 loc) · 891 Bytes
/
rustup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as vscode from "vscode";
import { Location } from "vs-verification-toolbox";
import * as util from "../util";
export async function ensureRustToolchainInstalled(context: vscode.ExtensionContext, toolchainFile: Location): Promise<void> {
util.log("Checking rust toolchain version and components...");
util.log(`Using rust-toolchain at ${toolchainFile}`);
if (!await toolchainFile.exists()) {
throw new Error(`The rust-toolchain file at ${toolchainFile} does not exist.`);
}
// `rustup show` will install the missing toolchain and components
const rustupOutput = await util.spawn(
"rustup",
["show"],
{ options: { cwd: toolchainFile.enclosingFolder.path() }}
);
if (rustupOutput.code != 0) {
throw new Error(`Rustup terminated with exit code ${rustupOutput.code} and signal ${rustupOutput.signal}`);
}
}