fix(create-vite): project name with only numbers as an argument#4606
Merged
patak-cat merged 3 commits intoAug 18, 2021
Merged
Conversation
…umber when an user input number-only project name
patak-cat
previously approved these changes
Aug 15, 2021
antfu
reviewed
Aug 15, 2021
| 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: ['_'] }) |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
@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.
patak-cat
reviewed
Aug 17, 2021
The comment before change was not helpful for understanding why option ( _ ) needs. Co-authored-by: patak <matias.capeletto@gmail.com>
Shinigami92
approved these changes
Aug 18, 2021
patak-cat
approved these changes
Aug 18, 2021
aleclarson
pushed a commit
to aleclarson/vite
that referenced
this pull request
Nov 8, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-vitecan 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).