MCPcopy
hub / github.com/t3-oss/create-t3-app / parseNameAndPath

Function parseNameAndPath

cli/src/utils/parseNameAndPath.ts:20–42  ·  view source on GitHub ↗
(rawInput: string)

Source from the content-addressed store, hash-verified

18 * - dir/app => ["app", "dir/app"]
19 */
20export const parseNameAndPath = (rawInput: string) => {
21 const input = removeTrailingSlash(rawInput);
22
23 const paths = input.split("/");
24
25 let appName = paths[paths.length - 1]!;
26
27 // If the user ran `npx create-t3-app .` or similar, the appName should be the current directory
28 if (appName === ".") {
29 const parsedCwd = pathModule.resolve(process.cwd());
30 appName = pathModule.basename(parsedCwd);
31 }
32
33 // If the first part is a @, it's a scoped package
34 const indexOfDelimiter = paths.findIndex((p) => p.startsWith("@"));
35 if (paths.findIndex((p) => p.startsWith("@")) !== -1) {
36 appName = paths.slice(indexOfDelimiter).join("/");
37 }
38
39 const path = paths.filter((p) => !p.startsWith("@")).join("/");
40
41 return [appName, path] as const;
42};

Callers 2

mainFunction · 0.85
dbContainerInstallerFunction · 0.85

Calls 1

removeTrailingSlashFunction · 0.85

Tested by

no test coverage detected