MCPcopy Create free account
hub / github.com/TanStack/cli / resolveProjectLocation

Function resolveProjectLocation

packages/cli/src/utils.ts:34–77  ·  view source on GitHub ↗
({
  projectName,
  targetDir,
  emptyProjectNameIsCurrentDirectory = false,
}: {
  projectName?: string
  targetDir?: string
  emptyProjectNameIsCurrentDirectory?: boolean
})

Source from the content-addressed store, hash-verified

32}
33
34export function resolveProjectLocation({
35 projectName,
36 targetDir,
37 emptyProjectNameIsCurrentDirectory = false,
38}: {
39 projectName?: string
40 targetDir?: string
41 emptyProjectNameIsCurrentDirectory?: boolean
42}): { projectName: string; targetDir: string } | undefined {
43 const normalizedProjectName = projectName?.trim() ?? ''
44
45 if (normalizedProjectName === '.') {
46 return {
47 projectName: getCurrentDirectoryPackageName(),
48 targetDir: resolve(process.cwd()),
49 }
50 }
51
52 if (normalizedProjectName) {
53 return {
54 projectName: normalizedProjectName,
55 targetDir: targetDir
56 ? resolve(targetDir)
57 : resolve(process.cwd(), normalizedProjectName),
58 }
59 }
60
61 if (targetDir) {
62 const resolvedTargetDir = resolve(targetDir)
63 return {
64 projectName: getDirectoryPackageName(resolvedTargetDir),
65 targetDir: resolvedTargetDir,
66 }
67 }
68
69 if (emptyProjectNameIsCurrentDirectory) {
70 return {
71 projectName: getCurrentDirectoryPackageName(),
72 targetDir: resolve(process.cwd()),
73 }
74 }
75
76 return undefined
77}
78
79export function validateProjectName(name: string) {
80 const { validForNewPackages, validForOldPackages, errors, warnings } =

Callers 2

promptForCreateOptionsFunction · 0.85
normalizeOptionsFunction · 0.85

Calls 2

getDirectoryPackageNameFunction · 0.85

Tested by

no test coverage detected