forked from arduino/arduino-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecutable-service-impl.ts
35 lines (32 loc) · 1.15 KB
/
executable-service-impl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { injectable, inject } from 'inversify';
import { ILogger } from '@theia/core/lib/common/logger';
import { FileUri } from '@theia/core/lib/node/file-uri';
import { getExecPath } from './exec-util';
import { ExecutableService } from '../common/protocol/executable-service';
@injectable()
export class ExecutableServiceImpl implements ExecutableService {
@inject(ILogger)
protected logger: ILogger;
async list(): Promise<{
clangdUri: string;
cliUri: string;
lsUri: string;
fwuploaderUri: string;
}> {
const [ls, clangd, cli, fwuploader] = await Promise.all([
getExecPath('arduino-language-server', this.onError.bind(this)),
getExecPath('clangd', this.onError.bind(this), undefined, true),
getExecPath('arduino-cli', this.onError.bind(this)),
getExecPath('arduino-fwuploader', this.onError.bind(this)),
]);
return {
clangdUri: FileUri.create(clangd).toString(),
cliUri: FileUri.create(cli).toString(),
lsUri: FileUri.create(ls).toString(),
fwuploaderUri: FileUri.create(fwuploader).toString(),
};
}
protected onError(error: Error): void {
this.logger.error(error);
}
}