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.
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 think simply replacing
args
instead of replacing thefullCustomCommand
would be more easy to understand.Would you also add a test here?
https://github.com/vitejs/vite/blob/main/packages/create-vite/__tests__/cli.spec.ts
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.
The code has been updated, but there seems to be something wrong with my device, could you help to add a test?
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.
When I add the test, I found that if
projectName
contains spaces, the value received byprogress.argv
will be split. Therefore,targetDir
can only get the characters before the spaces. How to deal with this scense? 🤔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.
In that case, I think the user should quote the project name (e.g.
npm init vite@latest "project name with spaces"
).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.
Yes, However, when executing
pnpm create vite
, the inputProject name
may contain spaces. I think that after the template is created, if the project name contains spaces, the project name should be wrapped in quotes in thecd projectName
output from the terminal.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.
So you're suggest updating this line? I think that makes sense.
vite/packages/create-vite/src/index.ts
Line 381 in 697dd00
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.
Yes, I think it should be updated here. And the previous modification is also necessary. But I don't know how to write this test 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.
I tried writing the test but it seems to be quite complex. I think we can go without tests.
If we replace this
execaCommandSync
withexecaSync
, we can test the case of passing the project name from argv.vite/packages/create-vite/__tests__/cli.spec.ts
Line 16 in 2ff5930
But for the case of typing the project name, we need to feed the text from stdin and the test seems to hang.