Skip to content

Commit

Permalink
Improve reliability of argv parsing (fixes #222)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Oct 15, 2024
1 parent 000f190 commit 49df37b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3204,14 +3204,16 @@ app.whenReady().then(() => {
}

// Check for file path given as argument
let argv = [...process.argv];
argv.shift(); // Remove executable path
if (!app.isPackaged) {
argv.shift(); // Remove bundle path in dev mode
}
argv = argv.filter((arg) => !arg.startsWith("--"));
if (argv.length > 0) {
firstOpenPath = argv[0];
let fileArgs = process.argv.filter(
(x) =>
x.endsWith(".wpilog") ||
x.endsWith(".rlog") ||
x.endsWith(".dslog") ||
x.endsWith(".dsevents") ||
x.endsWith(".hoot")
);
if (fileArgs.length > 0) {
firstOpenPath = fileArgs[0];
}

// Open file if exists
Expand Down

0 comments on commit 49df37b

Please sign in to comment.