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

fix: Bug where short flags are ignored #2131

Merged
merged 2 commits into from
Feb 22, 2021

Conversation

rschristian
Copy link
Contributor

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.

underfin
underfin previously approved these changes Feb 21, 2021
const debugIndex =
process.argv.indexOf('--debug') > 0
? process.argv.indexOf('--debug')
: process.argv.indexOf('-d')
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@jonaskuske jonaskuske Feb 21, 2021

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?)

@yyx990803 yyx990803 merged commit cbb3eff into vitejs:main Feb 22, 2021
@rschristian rschristian deleted the fix/shortFlags branch February 22, 2021 16:13
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

Successfully merging this pull request may close these issues.

4 participants