From 7ac07aa0ce9438135b5c0ef25e73c96ddf398f31 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Fri, 18 Apr 2025 21:43:46 -0700 Subject: [PATCH] Use npm as fallback if pnpm isn't available & more robust pnpm installation --- src/ipc/handlers/app_handlers.ts | 16 ++++++++++------ src/ipc/handlers/node_handlers.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ipc/handlers/app_handlers.ts b/src/ipc/handlers/app_handlers.ts index f31965c..00a90f8 100644 --- a/src/ipc/handlers/app_handlers.ts +++ b/src/ipc/handlers/app_handlers.ts @@ -65,12 +65,16 @@ async function executeAppLocalNode({ appId: number; event: Electron.IpcMainInvokeEvent; }): Promise { - const process = spawn("pnpm install && pnpm run dev --port 32100", [], { - cwd: appPath, - shell: true, - stdio: "pipe", // Ensure stdio is piped so we can capture output/errors and detect close - detached: false, // Ensure child process is attached to the main process lifecycle unless explicitly backgrounded - }); + const process = spawn( + "(pnpm install && pnpm run dev --port 32100) || (npm install && npm run dev -- --port 32100)", + [], + { + cwd: appPath, + shell: true, + stdio: "pipe", // Ensure stdio is piped so we can capture output/errors and detect close + detached: false, // Ensure child process is attached to the main process lifecycle unless explicitly backgrounded + } + ); // Check if process spawned correctly if (!process.pid) { diff --git a/src/ipc/handlers/node_handlers.ts b/src/ipc/handlers/node_handlers.ts index d72d24c..4b428e5 100644 --- a/src/ipc/handlers/node_handlers.ts +++ b/src/ipc/handlers/node_handlers.ts @@ -50,7 +50,7 @@ export function registerNodeHandlers() { // If not, try to install it using corepack. // If both fail, then pnpm is not available. checkCommandExists( - "pnpm --version || corepack enable pnpm && pnpm --version" + "pnpm --version || (corepack enable pnpm && pnpm --version) || (npm install -g pnpm@latest-10 && pnpm --version)" ), ]); // Default to mac download url.