-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathmise.ts
53 lines (45 loc) · 1.42 KB
/
mise.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* eslint-disable no-process-env */
import os from "os";
import * as vscode from "vscode";
import { VersionManager, ActivationResult } from "./versionManager";
// Mise (mise en place) is a manager for dev tools, environment variables and tasks
//
// Learn more: https://github.com/jdx/mise
export class Mise extends VersionManager {
async activate(): Promise<ActivationResult> {
const miseUri = await this.findMiseUri();
// The exec command in Mise is called `x`
const parsedResult = await this.runEnvActivationScript(
`${miseUri.fsPath} x -- ruby`,
);
return {
env: { ...process.env, ...parsedResult.env },
yjit: parsedResult.yjit,
version: parsedResult.version,
gemPath: parsedResult.gemPath,
};
}
async findMiseUri(): Promise<vscode.Uri> {
const config = vscode.workspace.getConfiguration("rubyLsp");
const misePath = config.get<string | undefined>(
"rubyVersionManager.miseExecutablePath",
);
const miseUri = misePath
? vscode.Uri.file(misePath)
: vscode.Uri.joinPath(
vscode.Uri.file(os.homedir()),
".local",
"bin",
"mise",
);
try {
await vscode.workspace.fs.stat(miseUri);
return miseUri;
} catch (error: any) {
// Couldn't find it
}
throw new Error(
`The Ruby LSP version manager is configured to be Mise, but ${miseUri.fsPath} does not exist`,
);
}
}