-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
fix: Bug where short flags are ignored #2131
Conversation
packages/vite/bin/vite.js
Outdated
const debugIndex = | ||
process.argv.indexOf('--debug') > 0 | ||
? process.argv.indexOf('--debug') | ||
: process.argv.indexOf('-d') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use check --d
instead of --debug
? It can inlcude two case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a much better idea, didn't think of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, actually, wouldn't that require looping through all of process.argv
? indexOf
is only going to return exact matches, as far as I know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this?
const debugIndex = process.argv.findIndex(arg => /^(?:-d|--debug)$/.test(arg))
Also prevents false positives in case some other command line argument starts with -d
.
(however, all of these implementations don't support --arg=value
syntax – is that intentional?)
472c3ee
to
285d5ad
Compare
Co-authored-by: Jonas <[email protected]>
285d5ad
to
c882ad3
Compare
I'm not entirely sure that this is the best version of the solution, but it solves an issue where the short flags for
--debug
and--filter
get ignored.I'm not sure if
--profile
needs the same treatment? I took a look around but didn't see where it was used, let alone if it should have a functional short flag.