Use ensureServerBinary instead

This commit is contained in:
Edwin Cheng 2020-02-21 09:57:24 +08:00
parent e7a0d8f8d0
commit 489be40d3a

View file

@ -1,10 +1,22 @@
import * as vscode from 'vscode';
import { ServerVersion } from '../installation/server';
import { Cmd } from '../ctx';
import { ensureServerBinary } from '../installation/server';
import { Ctx, Cmd } from '../ctx';
import { spawnSync } from 'child_process';
export function serverVersion(): Cmd {
return () => {
vscode.window.showInformationMessage('rust-analyzer version : ' + ServerVersion);
export function serverVersion(ctx: Ctx): Cmd {
return async () => {
const binaryPath = await ensureServerBinary(ctx.config.serverSource);
if (binaryPath == null) {
throw new Error(
"Rust Analyzer Language Server is not available. " +
"Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)."
);
}
const res = spawnSync(binaryPath, ["--version"]);
const version = res.output?.filter(x => x !== null).map(String).join(" ");
vscode.window.showInformationMessage('rust-analyzer version : ' + version);
};
}