mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Add distinction between `getInstance` and `getInstanceOrCreate` since it is not always possible to create an instance (since you might not know the correct arguments) - Remove all the `export const *Store = *Store.getInstance<*Store>();` calls as it defeats the purpose of `Singleton`. Plus with the typing changes the appropriate `*Store.getInstance()` is "short enough". - Special case the two extension export facades to not need to use `getInstanceOrCreate`. Plus since they are just facades it is always possible to create them. - Move some other types to be also `Singleton`'s: ExtensionLoader, ExtensionDiscovery, ThemeStore, LocalizationStore, ... - Fixed dev-run always using the same port with electron inspect - Update Store documentation with new recommendations about creating instances of singletons - Fix all unit tests to create their dependent singletons Signed-off-by: Sebastian Malton <sebastian@malton.name>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import path from "path";
|
|
import { helmCli } from "../helm/helm-cli";
|
|
import { UserStore } from "../../common/user-store";
|
|
import { ShellSession } from "./shell-session";
|
|
|
|
export class LocalShellSession extends ShellSession {
|
|
ShellType = "shell";
|
|
|
|
protected getPathEntries(): string[] {
|
|
return [helmCli.getBinaryDir()];
|
|
}
|
|
|
|
public async open() {
|
|
|
|
const env = await this.getCachedShellEnv();
|
|
const shell = env.PTYSHELL;
|
|
const args = await this.getShellArgs(shell);
|
|
|
|
super.open(env.PTYSHELL, args, env);
|
|
}
|
|
|
|
protected async getShellArgs(shell: string): Promise<string[]> {
|
|
const helmpath = helmCli.getBinaryDir();
|
|
const pathFromPreferences = UserStore.getInstance().preferences.kubectlBinariesPath || this.kubectl.getBundledPath();
|
|
const kubectlPathDir = UserStore.getInstance().preferences.downloadKubectlBinaries ? await this.kubectlBinDirP : path.dirname(pathFromPreferences);
|
|
|
|
switch(path.basename(shell)) {
|
|
case "powershell.exe":
|
|
return ["-NoExit", "-command", `& {Set-Location $Env:USERPROFILE; $Env:PATH="${helmpath};${kubectlPathDir};$Env:PATH"}`];
|
|
case "bash":
|
|
return ["--init-file", path.join(await this.kubectlBinDirP, ".bash_set_path")];
|
|
case "fish":
|
|
return ["--login", "--init-command", `export PATH="${helmpath}:${kubectlPathDir}:$PATH"; export KUBECONFIG="${this.kubeconfigPathP}"`];
|
|
case "zsh":
|
|
return ["--login"];
|
|
default:
|
|
return [];
|
|
}
|
|
}
|
|
}
|