fix: use process.defaultApp to detect packaged Electron app#692
Merged
mattgodbolt merged 1 commit intoMay 11, 2026
Merged
Conversation
The basename(argv[0]) === "jsbeeb" check never matched on Windows, where the packaged binary is jsbeeb.exe, so getArguments fell through to argv.slice(2) and silently dropped the first user argument. As a result "jsbeeb --noboot foo.dsd" autobooted (--noboot was discarded and foo.dsd became disc1) and "jsbeeb foo.dsd" did nothing (foo.dsd was discarded). Switch to process.defaultApp, which Electron sets only when running `electron .` in development, so the dev/packaged distinction is correct on every OS. Extracted getArguments into its own module so it can be unit-tested without booting Electron. Fixes mattgodbolt#684.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #684.
In getArguments the basename(argv[0]) === "jsbeeb" check never matched on Windows (the packaged binary is jsbeeb.exe), so the function fell through to argv.slice(2) and silently dropped the first user argument. That made "jsbeeb --noboot foo.dsd" appear to autoboot (--noboot was discarded and foo.dsd became disc1) and "jsbeeb foo.dsd" appear to do nothing (foo.dsd was discarded).
Switched to process.defaultApp, which Electron sets only when running
electron .in development, so the dev/packaged distinction is reliable across Linux, macOS, and Windows. Extracted getArguments into src/app/args.js so it can be unit-tested without booting Electron, and added tests/unit/test-app-args.js covering the Windows .exe case, the macOS .app/.../jsbeeb path, the Linux packaged path, dev mode, and the Chrome-flag filter.