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

Function toCleanPath

packages/create/src/edge-file-helpers.ts:14–31  ·  view source on GitHub ↗
(absolutePath: string, baseDir: string)

Source from the content-addressed store, hash-verified

12}
13
14export function toCleanPath(absolutePath: string, baseDir: string): string {
15 const normalizedPath = absolutePath.replace(/\\/g, '/')
16 const normalizedBase = baseDir.replace(/\\/g, '/')
17 let cleanPath = normalizedPath
18 if (normalizedPath.startsWith(normalizedBase)) {
19 cleanPath = normalizedPath.slice(normalizedBase.length)
20 } else if (hasDrive(normalizedPath) !== hasDrive(normalizedBase)) {
21 const pathNoDrive = stripDrive(normalizedPath)
22 const baseNoDrive = stripDrive(normalizedBase)
23 if (pathNoDrive.startsWith(baseNoDrive)) {
24 cleanPath = pathNoDrive.slice(baseNoDrive.length)
25 }
26 }
27 if (cleanPath.startsWith('/')) {
28 cleanPath = cleanPath.slice(1)
29 }
30 return cleanPath
31}
32
33export function relativePath(
34 from: string,

Callers 2

cleanUpFilesFunction · 0.70
cleanUpFileArrayFunction · 0.70

Calls 3

hasDriveFunction · 0.85
stripDriveFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected