Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fcee211

Browse files
authored
Merge pull request #26 from mads-hartmann/client-util-refactor
Simplify utility function for getting server command
2 parents a3d8ce7 + 8b5db74 commit fcee211

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

‎vscode-client/src/extension.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import {
77
ServerOptions,
88
} from 'vscode-languageclient'
99

10-
import *asUtil from './util'
10+
import {getServerCommand} from './util'
1111

1212
export function activate(context: ExtensionContext) {
13-
Util.base()
14-
.then(base => Util.executable(base))
13+
getServerCommand()
1514
.then(command => start(context, command))
1615
.catch(_ => handleMissingExecutable())
1716
}

‎vscode-client/src/util.ts‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import *asProcess from 'child_process'
1+
import {execFile} from 'child_process'
22
import * as Path from 'path'
33

44
function 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /