1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove explicit side-effect from getting default shell

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-03-29 15:06:09 +03:00
parent e2889c226b
commit 21f815bdea
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 28 additions and 10 deletions

View File

@ -0,0 +1,24 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
const defaultShellInjectable = getInjectable({
id: "default-shell",
instantiate: (di) => {
const isWindows = di.inject(isWindowsInjectable);
return (
process.env.SHELL ||
process.env.PTYSHELL ||
(isWindows ? "powershell.exe" : "System default shell")
);
},
causesSideEffects: true,
});
export default defaultShellInjectable;

View File

@ -8,7 +8,6 @@ import { observer } from "mobx-react";
import type { UserStore } from "../../../common/user-store";
import { SubTitle } from "../layout/sub-title";
import { Input, InputValidators } from "../input";
import { isWindows } from "../../../common/vars";
import { Switch } from "../switch";
import { Select } from "../select";
import type { ThemeStore } from "../../theme.store";
@ -16,21 +15,15 @@ import { Preferences } from "./preferences";
import { withInjectables } from "@ogre-tools/injectable-react";
import userStoreInjectable from "../../../common/user-store/user-store.injectable";
import themeStoreInjectable from "../../theme-store.injectable";
import defaultShellInjectable from "./default-shell.injectable";
interface Dependencies {
userStore: UserStore;
themeStore: ThemeStore;
defaultShell: string;
}
const NonInjectedTerminal = observer(({ userStore, themeStore }: Dependencies) => {
const defaultShell = process.env.SHELL
|| process.env.PTYSHELL
|| (
isWindows
? "powershell.exe"
: "System default shell"
);
const NonInjectedTerminal = observer(({ userStore, themeStore, defaultShell }: Dependencies) => {
return (
<Preferences data-testid="terminal-preferences-page">
<section>
@ -102,6 +95,7 @@ export const Terminal = withInjectables<Dependencies>(
getProps: (di) => ({
userStore: di.inject(userStoreInjectable),
themeStore: di.inject(themeStoreInjectable),
defaultShell: di.inject(defaultShellInjectable),
}),
},
);