fix(start): pass app args with correct amount of --
#3879
Merged
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.
Problem statement
Fixes #3873.
In #3848, we upgraded the
commander
library from v4 to v11, which brought in half a decade's worth of updates.This change required us to use the newer
passThroughOptions()
setting to pass args toprocess.argv
instead of to the program itself. I had previously tested that this worked specifically with the following invocation:However, as reported in the aforementioned issue, this approach didn't work with
yarn start yarn start -- -- --arg1 --arg2
when attempting to pass in app args without passing any args to Forge.Root cause
By inspecting the value of
process.argv
at the top level ofelectron-forge-start.ts
, I noticed that the--
values were being swallowed, leading to args being passed straight to the CLI instead of the app itself. However, all--
args were being passed properly to the top-levelelectron-forge.ts
file.I think I had
passThroughOptions
misconfigured by not setting it at the top level, meaning thatelectron-forge
would swallow one set of--
params even before it would touch theelectron-forge start
command level.Test cases
We don't have CLI-level tests in Forge, so I went around and tested this manually.
With
npm start
:With
yarn start
:With
npx electron-forge start
:Validating that there are no regressions with passing a CLI flag to Forge before passing additional args to the Electron app: