Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commander always expects a path as first argument #912

Closed
MYDIH opened this issue Feb 6, 2019 · 4 comments
Closed

Commander always expects a path as first argument #912

MYDIH opened this issue Feb 6, 2019 · 4 comments

Comments

@MYDIH
Copy link

MYDIH commented Feb 6, 2019

Hi,

I'm planing to use commander in an electron app. When the app is ran as is, without packaging, it works fine, but when the app is packaged (using electron-packager), the app complains about undefined path. I guess when packaged, the app do not receives the path of the executable as first argument. Is there a way to prevent commander from parsing this argument ?

I will open an issue on electron-packager too because I think don't passing the path as first argument is wrong. Could be cool to have a way to overcome this situation on the commander side too though.

Thanks

EDIT: electron-packager issue

EDIT2: After seing the answer on the electron-packager repo, I would say that commander is too optimistic about the fact that a node application will always be run using some kind of interpreter ...

@shadowspawn
Copy link
Collaborator

When you pass arguments to commander, it has no certain way of telling what the arguments are. The assumption, which is normally true, is that the first argument (argv[0]) is the running program and the second argument argv[1] is the script name or command name. Then your own arguments follow.

As suggested in the Electron issue, you can modify process.argv before calling commander, as you can tell how it was invoked.

@shadowspawn
Copy link
Collaborator

Also of interest, I found an older issue with lots of comments: #512

@MYDIH
Copy link
Author

MYDIH commented Mar 4, 2019

Thanks for the link. I managed to bypass the issue using a workaround (the one in the electron-packager repo). Still, there should be a way to address those special cases in commander's options.

@MYDIH MYDIH closed this as completed Mar 4, 2019
@shadowspawn
Copy link
Collaborator

Added implicit and explicit support for using Electron conventions: #1172

Search for Electron in README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants