diff --git a/vscode-client/src/extension.ts b/vscode-client/src/extension.ts index 34bb3fa8f..4014de86e 100644 --- a/vscode-client/src/extension.ts +++ b/vscode-client/src/extension.ts @@ -7,11 +7,10 @@ import { ServerOptions, } from 'vscode-languageclient' -import * as Util from './util' +import { getServerCommand } from './util' export function activate(context: ExtensionContext) { - Util.base() - .then(base => Util.executable(base)) + getServerCommand() .then(command => start(context, command)) .catch(_ => handleMissingExecutable()) } diff --git a/vscode-client/src/util.ts b/vscode-client/src/util.ts index e06246e91..3709e1a02 100644 --- a/vscode-client/src/util.ts +++ b/vscode-client/src/util.ts @@ -1,16 +1,13 @@ -import * as Process from 'child_process' +import { execFile } from 'child_process' import * as Path from 'path' function isWindows() { return process.platform === 'win32' } -/** - * - */ -export function base(): Promise { +function getBasePath(): Promise { return new Promise((resolve, reject) => { - Process.execFile('npm', ['bin', '-g'], (err, stdout) => { + execFile('npm', ['bin', '-g'], (err, stdout) => { if (err) { reject(err) } @@ -20,12 +17,14 @@ export function base(): Promise { }) } -export function executable(basePath: string): Promise { +export async function getServerCommand(): Promise { + const basePath = await getBasePath() const name = isWindows() ? 'bash-language-server.cmd' : 'bash-language-server' const command = Path.join(basePath, name) - return new Promise((resolve, reject) => { + + return new Promise((resolve, reject) => { // Simply check if the bash-language-server is installed. - Process.execFile(command, ['-v'], err => { + execFile(command, ['-v'], err => { if (err) { reject(err) }