diff options
| author | veetaha <veetaha2@gmail.com> | 2020-05-06 01:42:04 +0300 |
|---|---|---|
| committer | Craig Disselkoen <craigdissel@gmail.com> | 2020-05-05 16:12:56 -0700 |
| commit | c9b395be2bfcd67e045c1031143b7e8c27a6d3fb (patch) | |
| tree | 57ae8c2de16be47befcd115766fd15ceeb395a86 /editors/code/src/util.ts | |
| parent | a78dd06951dffcc6ff69aec21a2d8224c12f5026 (diff) | |
| download | rust-c9b395be2bfcd67e045c1031143b7e8c27a6d3fb.tar.gz rust-c9b395be2bfcd67e045c1031143b7e8c27a6d3fb.zip | |
Fix cargo not found on macos bug at vscode extension side
Diffstat (limited to 'editors/code/src/util.ts')
| -rw-r--r-- | editors/code/src/util.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 6f91f81d63e..127a9e91124 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -1,6 +1,7 @@ import * as lc from "vscode-languageclient"; import * as vscode from "vscode"; import { strict as nativeAssert } from "assert"; +import { spawnSync } from "child_process"; export function assert(condition: boolean, explanation: string): asserts condition { try { @@ -82,3 +83,13 @@ export function isRustDocument(document: vscode.TextDocument): document is RustD export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor { return isRustDocument(editor.document); } + +export function isValidExecutable(path: string): boolean { + log.debug("Checking availability of a binary at", path); + + const res = spawnSync(path, ["--version"], { encoding: 'utf8' }); + + log.debug(res, "--version output:", res.output); + + return res.status === 0; +} |
