Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/toolchain.ts')
-rw-r--r--editors/code/src/toolchain.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index 917a1d6b09..014e6b66f6 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -4,6 +4,8 @@ import * as path from "path";
import * as readline from "readline";
import * as vscode from "vscode";
import { execute, log, memoizeAsync } from "./util";
+import { unwrapNullable } from "./nullable";
+import { unwrapUndefinable } from "./undefinable";
interface CompilationArtifact {
fileName: string;
@@ -93,7 +95,8 @@ export class Cargo {
throw new Error("Multiple compilation artifacts are not supported.");
}
- return artifacts[0].fileName;
+ const artifact = unwrapUndefinable(artifacts[0]);
+ return artifact.fileName;
}
private async runCargo(
@@ -142,7 +145,9 @@ export async function getRustcId(dir: string): Promise<string> {
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
const rx = /commit-hash:\s(.*)$/m;
- return rx.exec(data)![1];
+ const result = unwrapNullable(rx.exec(data));
+ const first = unwrapUndefinable(result[1]);
+ return first;
}
/** Mirrors `toolchain::cargo()` implementation */
@@ -171,7 +176,7 @@ export const getPathForExecutable = memoizeAsync(
);
async function lookupInPath(exec: string): Promise<boolean> {
- const paths = process.env.PATH ?? "";
+ const paths = process.env["PATH"] ?? "";
const candidates = paths.split(path.delimiter).flatMap((dirInPath) => {
const candidate = path.join(dirInPath, exec);