Skip to content
Source
Sign inSign up
TanStack/cli

Fix/window path #330

Mergedjong-kyung(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/330/headmerged by tannerlinsley

Showing 3 changed files with 26 additions and 1 deletion.

x
0 of 3 viewed, 3 left
12 additions and 1 deletionpackages/create/src/file-helpers.tsModified
View file
@@ -4,6 +4,7 @@
import parseGitignore from 'parse-gitignore'
import ignore from 'ignore'
​
+import { hasDrive, stripDrive } from './utils'
import type { Environment } from './types'
​
const BINARY_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico']
@@ -43,7 +44,17 @@
// Normalize both paths to use forward slashes for consistent comparison
const normalizedPath = absolutePath.replace(/\\/g, '/')
const normalizedBase = baseDir.replace(/\\/g, '/')
- let cleanPath = normalizedPath.replace(normalizedBase, '')
+ let cleanPath = normalizedPath
+ if (normalizedPath.startsWith(normalizedBase)) {
+ cleanPath = normalizedPath.slice(normalizedBase.length)
+ } else if (hasDrive(normalizedPath) !== hasDrive(normalizedBase)) {
+ // Handle paths that are missing the Windows drive letter (e.g. memfs on Windows)
+ const pathNoDrive = stripDrive(normalizedPath)
+ const baseNoDrive = stripDrive(normalizedBase)
+ if (pathNoDrive.startsWith(baseNoDrive)) {
+ cleanPath = pathNoDrive.slice(baseNoDrive.length)
+ }
+ }
// Handle leading path separator