Closed Ankcorn closed 1 year ago
The behaviour is as expected. Options may appear before or after positional arguments, and the argument is being treated as an option since it starts with a double-dash.
To get the behaviour you want, use --
to stop the option processing. Say:
[
'--add',
'--env',
'--',
'staging',
'NODE_OPTIONS',
'--require node_modules/test/index'
]
Thank you :smiling_face_with_tear:
I'll add one more thing.
--
is good for when the end-user is trying to pass something tricky.
If as author you always want this behaviour and have a usage pattern where there are some plain positional arguments before any with a dash, you might be able to use opts.stopEarly
. It is intended more for implementing subcommands but might be useful in this case too.
When I run minimist with the following input
The final arg is added as a named argument.
My desired output would be
I suspect this is a bug