Reload env path instead of restarting dyad app after node.js install

This commit is contained in:
Will Chen
2025-04-18 10:11:59 -07:00
parent 8d9aab214c
commit cc0ab0fd56
4 changed files with 62 additions and 24 deletions

View File

@@ -1,7 +1,8 @@
import { ipcMain, app } from "electron";
import { spawn } from "child_process";
import { exec, execSync, spawn } from "child_process";
import { platform, arch } from "os";
import { NodeSystemInfo } from "../ipc_types";
import fixPath from "fix-path";
function checkCommandExists(command: string): Promise<string | null> {
return new Promise((resolve) => {
@@ -68,8 +69,16 @@ export function registerNodeHandlers() {
return { nodeVersion, pnpmVersion, nodeDownloadUrl };
});
ipcMain.handle("reload-dyad", async (): Promise<void> => {
app.relaunch();
app.exit(0);
ipcMain.handle("reload-env-path", async (): Promise<void> => {
console.debug("Reloading env path, previously:", process.env.PATH);
if (platform() === "win32") {
const newPath = execSync("cmd /c echo %PATH%", {
encoding: "utf8",
}).trim();
process.env.PATH = newPath;
} else {
fixPath();
}
console.debug("Reloaded env path, now:", process.env.PATH);
});
}