From ef223b9e6439c228e0be49861efd2067c0b22af4 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Mon, 6 Jul 2020 13:39:08 +0300 Subject: Fix: allow for binaries from $PATH to pass validity check --- editors/code/src/util.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'editors/code') diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 78fe6f5da..970fedb37 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 */ -- cgit v1.2.3