Skip to content

Commit

Permalink
support providing meshchat command line args to portable electron exe
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Jul 9, 2024
1 parent e71e562 commit a804e16
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,24 @@ app.whenReady().then(async () => {
fs.renameSync(oldStorageDir, storageDir);
}

// spawn executable
exeChildProcess = await spawn(exe, [
// get arguments passed to application, and remove the provided application path
const userProvidedArguments = process.argv.slice(1);

// arguments we always want to pass in
const requiredArguments = [
'--headless', // reticulum meshchat usually launches default web browser, we don't want this when using electron
'--port', '9337', // FIXME: let system pick a random unused port?
'--storage-dir', storageDir,
];

// if user didn't provide storage dir, we should provide it
if(!userProvidedArguments.includes("--storage-dir")){
requiredArguments.push("--storage-dir", storageDir);
}

// spawn executable
exeChildProcess = await spawn(exe, [
...requiredArguments, // always provide required arguments
...userProvidedArguments, // also include any user provided arguments
]);

// log stdout
Expand Down

0 comments on commit a804e16

Please sign in to comment.