aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/toolchain.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/toolchain.ts')
-rw-r--r--editors/code/src/toolchain.ts19
1 files changed, 6 insertions, 13 deletions
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index 68826c478..ba1b8617a 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -1,9 +1,8 @@
1import * as cp from 'child_process'; 1import * as cp from 'child_process';
2import * as os from 'os'; 2import * as os from 'os';
3import * as path from 'path'; 3import * as path from 'path';
4import * as fs from 'fs';
5import * as readline from 'readline'; 4import * as readline from 'readline';
6import { OutputChannel } from 'vscode'; 5import * as vscode from 'vscode';
7import { execute, log, memoize } from './util'; 6import { execute, log, memoize } from './util';
8 7
9interface CompilationArtifact { 8interface CompilationArtifact {
@@ -19,7 +18,7 @@ export interface ArtifactSpec {
19} 18}
20 19
21export class Cargo { 20export class Cargo {
22 constructor(readonly rootFolder: string, readonly output: OutputChannel) { } 21 constructor(readonly rootFolder: string, readonly output: vscode.OutputChannel) { }
23 22
24 // Made public for testing purposes 23 // Made public for testing purposes
25 static artifactSpec(args: readonly string[]): ArtifactSpec { 24 static artifactSpec(args: readonly string[]): ArtifactSpec {
@@ -158,9 +157,9 @@ export const getPathForExecutable = memoize(
158 try { 157 try {
159 // hmm, `os.homedir()` seems to be infallible 158 // hmm, `os.homedir()` seems to be infallible
160 // it is not mentioned in docs and cannot be infered by the type signature... 159 // it is not mentioned in docs and cannot be infered by the type signature...
161 const standardPath = path.join(os.homedir(), ".cargo", "bin", executableName); 160 const standardPath = vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".cargo", "bin", executableName);
162 161
163 if (isFile(standardPath)) return standardPath; 162 if (isFile(standardPath.path)) return standardPath.path;
164 } catch (err) { 163 } catch (err) {
165 log.error("Failed to read the fs info", err); 164 log.error("Failed to read the fs info", err);
166 } 165 }
@@ -181,12 +180,6 @@ function lookupInPath(exec: string): boolean {
181 return candidates.some(isFile); 180 return candidates.some(isFile);
182} 181}
183 182
184function isFile(suspectPath: string): boolean { 183async function isFile(path: string): Promise<boolean> {
185 // It is not mentionned in docs, but `statSync()` throws an error when 184 return ((await vscode.workspace.fs.stat(vscode.Uri.file(path))).type & vscode.FileType.File) != 0;
186 // the path doesn't exist
187 try {
188 return fs.statSync(suspectPath).isFile();
189 } catch {
190 return false;
191 }
192} 185}