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

Function normalizePath

packages/create/src/edge-path.ts:1–27  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

1export function normalizePath(path: string): string {
2 const normalized = path.replace(/\\/g, '/')
3 const isAbsolute = normalized.startsWith('/')
4 const parts: Array<string> = []
5
6 for (const part of normalized.split('/')) {
7 if (!part || part === '.') {
8 continue
9 }
10 if (part === '..') {
11 if (parts.length && parts[parts.length - 1] !== '..') {
12 parts.pop()
13 } else if (!isAbsolute) {
14 parts.push(part)
15 }
16 continue
17 }
18 parts.push(part)
19 }
20
21 const joined = parts.join('/')
22 if (isAbsolute) {
23 return joined ? `/${joined}` : '/'
24 }
25
26 return joined || '.'
27}
28
29export function joinPaths(...paths: Array<string | undefined>): string {
30 const filtered = paths.filter(

Callers 9

installShadcnComponentsFunction · 0.70
setupIntentFunction · 0.70
reportFunction · 0.70
joinPathsFunction · 0.70
basenamePathFunction · 0.70
dirnamePathFunction · 0.70
hasDirectoryFunction · 0.70
createMemoryEnvironmentFunction · 0.70

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected