-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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(create-vite): project name with only numbers as an argument #4606
fix(create-vite): project name with only numbers as an argument #4606
Conversation
…umber when an user input number-only project name
@@ -3,7 +3,7 @@ | |||
// @ts-check | |||
const fs = require('fs') | |||
const path = require('path') | |||
const argv = require('minimist')(process.argv.slice(2)) | |||
const argv = require('minimist')(process.argv.slice(2), { string: ['_'] }) |
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.
I found it's hard to understand what's going on. We'd better add a comment for that, or just use toString()
on usage.
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.
@antfu
Thanks for your comment!
I agree with it's hard to undarstand what's going on. So, I've added a comment for that.
Could you review that?
Thanks.
The comment before change was not helpful for understanding why option ( _ ) needs. Co-authored-by: patak <[email protected]>
Description
If an argument for the project name is set only with numbers, path.join will be failed because the argument is retained in "number" type.
On entering the project name interactively, the type conversion to "string" type is implicitly performed because "trim" method is called in the middle.
I think it is strange that
create-vite
can generate a project with numbers on setting interactively, but not on setting it with arguments.Additional context
The reason why happened that, it is automatically converted to "number" type, on not setting an option for "minimist", which is a library for managing arguments.
ref: https://github.com/substack/minimist/blob/aeb3e27dae0412de5c0494e9563a5f10c82cc7a9/index.js#L59-L61
I would like to attach the failed log for an reference.
Moreover, I would like to attach the succeeded log for an reference.
(2021-08-15 added)
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).