about summary refs log tree commit diff
path: root/editors/code/src/util.ts
diff options
context:
space:
mode:
authorVeetaha <veetaha2@gmail.com>2020-07-06 13:39:08 +0300
committerVeetaha <veetaha2@gmail.com>2020-07-06 13:41:38 +0300
commitef223b9e6439c228e0be49861efd2067c0b22af4 (patch)
tree6a4cbf2eb92a1e160397416e212420de9281ab9d /editors/code/src/util.ts
parent46163acf62a94ec603be444294e119933c953a84 (diff)
downloadrust-ef223b9e6439c228e0be49861efd2067c0b22af4.tar.gz
rust-ef223b9e6439c228e0be49861efd2067c0b22af4.zip
Fix: allow for binaries from $PATH to pass validity check
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r--editors/code/src/util.ts8
1 files changed, 2 insertions, 6 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 78fe6f5dab9..970fedb3787 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,5 +1,4 @@
 import * as lc from "vscode-languageclient";
-import * as fs from "fs";
 import * as vscode from "vscode";
 import { strict as nativeAssert } from "assert";
 import { spawnSync } from "child_process";
@@ -114,15 +113,12 @@ export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
 export function isValidExecutable(path: string): boolean {
     log.debug("Checking availability of a binary at", path);
 
-    if (!fs.existsSync(path)) return false;
-
     const res = spawnSync(path, ["--version"], { encoding: 'utf8' });
 
-    const isSuccess = res.status === 0;
-    const printOutput = isSuccess ? log.debug : log.warn;
+    const printOutput = res.error && (res.error as any).code !== 'ENOENT' ? log.warn : log.debug;
     printOutput(path, "--version:", res);
 
-    return isSuccess;
+    return res.status === 0;
 }
 
 /** Sets ['when'](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts) clause contexts */