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

feat: set appName to directory on 'npx create-t3-app .' #273

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/utils/parseNameAndPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Parses the appName and its path from the user input.
* Returns an array of [appName, path] where appName is the name put in the package.json and
* path is the path to the directory where the app will be created.
* If the appName is '.', the name of the directory will be used instead.
* Handles the case where the input includes a scoped package name
* in which case that is being parsed as the name, but not included as the path
* e.g. dir/@mono/app => ["@mono/app", "dir/app"]
Expand All @@ -12,6 +13,11 @@ export const parseNameAndPath = (input: string) => {

let appName = paths[paths.length - 1];

// If the user ran `npx create-t3-app .` or similar, the appName should be the current directory
if (appName === ".") {
appName = process.cwd().split("/").pop();
}

// If the first part is a @, it's a scoped package
const indexOfDelimiter = paths.findIndex((p) => p.startsWith("@"));
if (paths.findIndex((p) => p.startsWith("@")) !== -1) {
Expand Down