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

Set project name automatically when target includes a path #16470

Open
4 tasks done
brownieboy opened this issue Apr 19, 2024 · 0 comments · May be fixed by #16490
Open
4 tasks done

Set project name automatically when target includes a path #16470

brownieboy opened this issue Apr 19, 2024 · 0 comments · May be fixed by #16490

Comments

@brownieboy
Copy link

brownieboy commented Apr 19, 2024

Description

As a Developer create apps with create-vite, I want to specify a file path in the first parameter and then have the project name automatically set from the last part of that path, i.e. the path.basename() of that path. So for a command like this:

npm create vite ../../myfolder/myapp -- --template react

The project name should be set to "myapp", with no further prompting of the user.

At present, if create-vite detects a path in the first parameter then it will prompt for the project name, offering a default of something like "-myapp".

Suggested solution

Should be able to implement in file packages/create-vite/src/index.ts, by changing the getProjectName function from this:

const getProjectName = () =>
    targetDir === '.' ? path.basename(path.resolve()) : targetDir

to this:

  const getProjectName = () => path.basename(path.resolve(targetDir))

Alternative

No response

Additional context

This is how create-react-app behaves, so would help smooth the path to create-vite for create-react-app refugees (like me!).

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant