Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Manually activate shadow env instead of depending on extension
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Jul 17, 2023
1 parent 744609c commit ec50daf
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,24 @@ export class Ruby {
}

private async activateShadowenv() {
const extension = vscode.extensions.getExtension(
"shopify.vscode-shadowenv"
);

if (!extension) {
throw new Error(
"The Ruby LSP version manager is configured to be shadowenv, but the shadowenv extension is not installed"
);
}

if (!fs.existsSync(path.join(this.workingFolder, ".shadowenv.d"))) {
throw new Error(
"The Ruby LSP version manager is configured to be shadowenv, \
but no .shadowenv.d directory was found in the workspace"
);
}

await extension.activate();
await this.delay(500);
const result = await asyncExec("shadowenv hook --json", {
cwd: this.workingFolder,
});

const env = JSON.parse(result.stdout).exported;

// The only reason we set the process environment here is to allow other extensions that don't perform activation
// work properly
// eslint-disable-next-line no-process-env
this._env = { ...process.env };
process.env = env;
this._env = env;
}

private async activateChruby() {
Expand Down Expand Up @@ -297,12 +294,6 @@ export class Ruby {
}
}

private async delay(mseconds: number) {
return new Promise((resolve) => {
setTimeout(resolve, mseconds);
});
}

private async activateCustomRuby() {
const configuration = vscode.workspace.getConfiguration("rubyLsp");
const customCommand: string | undefined =
Expand Down

0 comments on commit ec50daf

Please sign in to comment.