-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add auto-detection of args when node evaluating script code on command-line #2164
Conversation
I am thinking the "node" mode should be smart about eval/print too, since it is a node behaviour, and would be quite like the "electron" behaviour. And being more explicit in the README that no arguments is the auto-detect mode and "node" is the default if arguments are supplied. And whether changing explicit "node" mode may make it a breaking semver-major change for the few people who have already coded it themselves. 😢 I think perhaps so, since the README is quite explicit about the existing behaviour:
|
I decided I am happy with the full-auto just when Commander is deciding everything! Supplied arguments means we don't know where they came from, so play safe and assume normal node. Did big rework of docs. Might be overkill for the JSDoc/TSDoc, but parse is a fundamental method to get right. (Could trim it down if too much!) |
Pull Request
Problem
program.parse()
will not detect the user arguments correctly when script supplied withnode --print "script..."
ornode --eval "script..."
.See: #2163
Solution
Look for the relevant options in
process.execArgv
to detect these special cases.References:
ChangeLog
node --eval
andnode --print
when call.parse()
with no arguments