Stop using @electron/remote to obtain app.getPath() (#4078)

* Stop using remote to obtain app.getPath()

- Initialize entire map in bootstrap()

- Updated unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Resolve PR comments

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix test

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix build

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Ensure that init can only be called once and catch errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Replace basically all uses of app.getPath() with AppPaths.get()

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-10-27 21:07:41 -04:00
1 parent 65b6908bf1
commit f297407156
45 files changed
+521 -200

No files matched your search

+3 -9
View File
@@ -63,13 +63,12 @@ import { ensureDir } from "fs-extra";
import { Router } from "./router";
import { initMenu } from "./menu";
import { initTray } from "./tray";
import * as path from "path";
import { kubeApiRequest, shellApiRequest } from "./proxy-functions";
import { AppPaths } from "../common/app-paths";
const onCloseCleanup = disposer();
const onQuitCleanup = disposer();
const workingDir = path.join(app.getPath("appData"), appName);
SentryInit();
app.setName(appName);
@@ -82,12 +81,7 @@ if (app.setAsDefaultProtocolClient("lens")) {
logger.info("📟 Protocol client register failed ❗");
}
if (process.env.CICD) {
app.setPath("appData", process.env.CICD);
app.setPath("userData", path.join(process.env.CICD, appName));
} else {
app.setPath("userData", workingDir);
}
AppPaths.init();
if (process.env.LENS_DISABLE_GPU) {
app.disableHardwareAcceleration();
@@ -127,7 +121,7 @@ app.on("second-instance", (event, argv) => {
});
app.on("ready", async () => {
logger.info(`🚀 Starting ${productName} from "${app.getPath("exe")}"`);
logger.info(`🚀 Starting ${productName} from "${AppPaths.get("exe")}"`);
logger.info("🐚 Syncing shell environment");
await shellSync();