-
Notifications
You must be signed in to change notification settings - Fork 10
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
Second argument (first in process.argv
) is always ignored.
#146
Comments
process.argv
) is always ignored.
Such a compiler should probably be wrapping or building modules such that process.argv has a fictional argument added - otherwise all code that assumes “what node always does” would break. |
@ljharb thank you for the reply, I've actually verified the polyfill behaves exactly the same as Node (not sure why I expected it to work better than this polyfill in terms of the logic) and such compilance is what I think people should care about. That being said, I feel like I'll close this issue for now. It might be useful to reopen it after some time, given how many Node.js-based frameworks and tools are there that actually don't care about Node's |
If your runtime environment follows different conventions than node does with
The arguments to be parsed were originally a separate parameter, but the normal case is they can be auto-detected so after some discussion they were moved into the configuration. (For interest, there was explicit support for detecting Electron in the initial submission to the node project, but that got dropped during the pull request to node. Likewise, there was also a suggestion for a |
Yeah, that's what I want to do for now. I just thought Node will take care of the argv better, given how default
This is very non-intuitive description of what's done for those who use Node-based frameworks or mess with |
Oh right, makes it sound smarter than it is! Thanks for clarifying source of confusion. |
Current implementation of
@pkgjs/parseargs
assumes this to be always correct:parseargs/index.js
Lines 69 to 70 in 6774908
However, in some enviroments, either script is compiled to the executable like in case of
pkg
-packaged scripts or there'snode
binary (e.g.electron
or any other web app framework using Node) that calls the script directly, without any need of passing an additional argument for a path to the script. Moreover, I think path could be passed after flags rather than before, which would also cause some inconstancy between the polyfill and native API.Maybe the code should be prepared for those cases as well?
The text was updated successfully, but these errors were encountered: