From 8b41475edd277c29cc3878269f856b6fde3e1d46 Mon Sep 17 00:00:00 2001 From: Christopher Ehrlich Date: Mon, 1 Aug 2022 18:14:33 +0200 Subject: [PATCH] feat: set appName to directory on 'npx create-t3-app .' --- src/utils/parseNameAndPath.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/parseNameAndPath.ts b/src/utils/parseNameAndPath.ts index 97425828b9..911fdde3cb 100644 --- a/src/utils/parseNameAndPath.ts +++ b/src/utils/parseNameAndPath.ts @@ -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"] @@ -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) {