Skip to content

Commit

Permalink
Fix: pass working directory for spawn command (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKhalow authored Dec 6, 2024
1 parent a05b924 commit ff50643
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/main/src/modules/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'path';
import { join, dirname } from 'path';
import fs from 'node:fs';
import { spawn } from 'child_process';
import { app, BrowserWindow, ipcMain } from 'electron';
Expand Down Expand Up @@ -196,6 +196,7 @@ export async function launchExplorer(event: Electron.IpcMainInvokeEvent, version
analytics.track(ANALYTICS_EVENT.LAUNCH_CLIENT_START, { version: versionData.version });

const explorerBinPath = getExplorerBinPath(version);
const explorerBinDir = dirname(explorerBinPath);

if (!fs.existsSync(explorerBinPath)) {
const errorMessage = version ? `The explorer version specified: ${version} is not installed.` : 'The explorer is not installed.';
Expand All @@ -221,7 +222,7 @@ export async function launchExplorer(event: Electron.IpcMainInvokeEvent, version
analytics.getSessionId(),
].filter(arg => !!arg);
log.info('[Main Window][IPC][LaunchExplorer] Opening the Explorer', explorerParams);
spawn(explorerBinPath, explorerParams, { detached: true, stdio: 'ignore' })
spawn(explorerBinPath, explorerParams, { cwd: explorerBinDir, detached: true, stdio: 'ignore' })
.on('spawn', async () => {
event.sender.send(IPC_EVENTS.LAUNCH_EXPLORER, { type: IPC_EVENT_DATA_TYPE.LAUNCHED });
await analytics.track(ANALYTICS_EVENT.LAUNCH_CLIENT_SUCCESS, { version: versionData.version });
Expand Down

0 comments on commit ff50643

Please sign in to comment.