1
- import * as Process from 'child_process'
1
+ import { execFile } from 'child_process'
2
2
import * as Path from 'path'
3
3
4
4
function isWindows ( ) {
5
5
return process . platform === 'win32'
6
6
}
7
7
8
- /**
9
- *
10
- */
11
- export function base ( ) : Promise < string > {
8
+ function getBasePath ( ) : Promise < string > {
12
9
return new Promise ( ( resolve , reject ) => {
13
- Process . execFile ( 'npm' , [ 'bin' , '-g' ] , ( err , stdout ) => {
10
+ execFile ( 'npm' , [ 'bin' , '-g' ] , ( err , stdout ) => {
14
11
if ( err ) {
15
12
reject ( err )
16
13
}
@@ -20,12 +17,14 @@ export function base(): Promise<string> {
20
17
} )
21
18
}
22
19
23
- export function executable ( basePath : string ) : Promise < string > {
20
+ export async function getServerCommand ( ) : Promise < string > {
21
+ const basePath = await getBasePath ( )
24
22
const name = isWindows ( ) ? 'bash-language-server.cmd' : 'bash-language-server'
25
23
const command = Path . join ( basePath , name )
26
- return new Promise ( ( resolve , reject ) => {
24
+
25
+ return new Promise < string > ( ( resolve , reject ) => {
27
26
// Simply check if the bash-language-server is installed.
28
- Process . execFile ( command , [ '-v' ] , err => {
27
+ execFile ( command , [ '-v' ] , err => {
29
28
if ( err ) {
30
29
reject ( err )
31
30
}
0 commit comments