forked from smithy-lang/smithy-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoursier.ts
More file actions
22 lines (19 loc) · 798 Bytes
/
coursier.ts
File metadata and controls
22 lines (19 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as child_process from 'child_process';
import * as vscode from 'vscode';
import downloadCoursierIfRequired from './download-coursier';
export default async function getCoursierExecutable(context: vscode.ExtensionContext): Promise<string> {
for (const command of ['cs', 'coursier']) {
if (await availableOnPath(command, ['--help'])) {
return command;
}
}
console.log('Coursier not found on path, downloading it instead.');
return await downloadCoursierIfRequired(context.globalStoragePath, 'v2.0.6');
}
function availableOnPath(command: string, args: string[]): Promise<boolean> {
return new Promise((resolve, reject) => {
child_process.execFile(command, args, (e, _, __) => {
resolve(e == null);
});
});
}