-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathcustom.ts
39 lines (33 loc) · 1.32 KB
/
custom.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
/* eslint-disable no-process-env */
import * as vscode from "vscode";
import { VersionManager, ActivationResult } from "./versionManager";
// Custom
//
// Custom Ruby environment activation can be used for all cases where an existing version manager does not suffice.
// Users are allowed to define a shell script that runs before calling ruby, giving them the chance to modify the PATH,
// GEM_HOME and GEM_PATH as needed to find the correct Ruby runtime.
export class Custom extends VersionManager {
async activate(): Promise<ActivationResult> {
const parsedResult = await this.runEnvActivationScript(
`${this.customCommand()} && ruby`,
);
return {
env: { ...process.env, ...parsedResult.env },
yjit: parsedResult.yjit,
version: parsedResult.version,
gemPath: parsedResult.gemPath,
};
}
customCommand() {
const configuration = vscode.workspace.getConfiguration("rubyLsp");
const customCommand: string | undefined =
configuration.get("customRubyCommand");
if (customCommand === undefined) {
throw new Error(
"The customRubyCommand configuration must be set when 'custom' is selected as the version manager. \
See the [README](https://shopify.github.io/ruby-lsp/version-managers.html) for instructions.",
);
}
return customCommand;
}
}