1- import * as Process from 'child_process'
1+ import { execFile } from 'child_process'
22import * as Path from 'path'
33
44function isWindows ( ) {
55 return process . platform === 'win32'
66}
77
8- /**
9- *
10- */
11- export function base ( ) : Promise < string > {
8+ function getBasePath ( ) : Promise < string > {
129 return new Promise ( ( resolve , reject ) => {
13- Process . execFile ( 'npm' , [ 'bin' , '-g' ] , ( err , stdout ) => {
10+ execFile ( 'npm' , [ 'bin' , '-g' ] , ( err , stdout ) => {
1411 if ( err ) {
1512 reject ( err )
1613 }
@@ -20,12 +17,14 @@ export function base(): Promise<string> {
2017 } )
2118}
2219
23- export function executable ( basePath : string ) : Promise < string > {
20+ export async function getServerCommand ( ) : Promise < string > {
21+ const basePath = await getBasePath ( )
2422 const name = isWindows ( ) ? 'bash-language-server.cmd' : 'bash-language-server'
2523 const command = Path . join ( basePath , name )
26- return new Promise ( ( resolve , reject ) => {
24+
25+ return new Promise < string > ( ( resolve , reject ) => {
2726 // Simply check if the bash-language-server is installed.
28- Process . execFile ( command , [ '-v' ] , err => {
27+ execFile ( command , [ '-v' ] , err => {
2928 if ( err ) {
3029 reject ( err )
3130 }
0 commit comments