diff options
Diffstat (limited to 'editors/code/src/toolchain.ts')
-rw-r--r-- | editors/code/src/toolchain.ts | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 68826c478..902d0ddda 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import * as cp from 'child_process'; | 1 | import * as cp from 'child_process'; |
2 | import * as os from 'os'; | 2 | import * as os from 'os'; |
3 | import * as path from 'path'; | 3 | import * as path from 'path'; |
4 | import * as fs from 'fs'; | ||
5 | import * as readline from 'readline'; | 4 | import * as readline from 'readline'; |
6 | import { OutputChannel } from 'vscode'; | 5 | import * as vscode from 'vscode'; |
7 | import { execute, log, memoize } from './util'; | 6 | import { execute, log, memoize } from './util'; |
8 | 7 | ||
9 | interface CompilationArtifact { | 8 | interface CompilationArtifact { |
@@ -19,7 +18,7 @@ export interface ArtifactSpec { | |||
19 | } | 18 | } |
20 | 19 | ||
21 | export class Cargo { | 20 | export 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 | ||
184 | function isFile(suspectPath: string): boolean { | 183 | async 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 | } |