File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,26 @@ export function getBinaryFile(content: string): string | null {
37
37
}
38
38
39
39
export function relativePath ( from : string , to : string ) {
40
- const cleanedFrom = from . startsWith ( './' ) ? from . slice ( 2 ) : from
40
+ const fixedOnWindows = from . startsWith ( '.\\' )
41
+ ? from . replace ( / \\ / g, '/' )
42
+ : from
43
+ const cleanedFrom = fixedOnWindows . startsWith ( './' )
44
+ ? fixedOnWindows . slice ( 2 )
45
+ : from
41
46
const cleanedTo = to . startsWith ( './' ) ? to . slice ( 2 ) : to
42
47
48
+ const fromSegments = cleanedFrom . split ( '/' )
49
+ const toSegments = cleanedTo . split ( '/' )
50
+
43
51
if ( process . env . CTA_DEBUG ) {
52
+ console . log ( 'process.platform' , process . platform )
53
+ console . log ( 'fixedOnWindows' , fixedOnWindows )
44
54
console . log ( 'from' , from )
45
55
console . log ( 'to' , to )
46
56
console . log ( 'cleanedFrom' , cleanedFrom )
47
57
console . log ( 'cleanedTo' , cleanedTo )
48
58
}
49
59
50
- const fromSegments = cleanedFrom . split ( '/' )
51
- const toSegments = cleanedTo . split ( '/' )
52
-
53
60
fromSegments . pop ( )
54
61
toSegments . pop ( )
55
62
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ describe('relativePath', () => {
47
47
) ,
48
48
) . toBe ( '../integrations/tanstack-query/layout.tsx' )
49
49
} )
50
- // it('windows', () => {
51
- // expect(
52
- // relativePath(
53
- // 'c:\\test-app\\ src\\main.tsx',
54
- // 'src/integrations/tanstack-query/root-provider.tsx',
55
- // ),
56
- // ).toBe('./integrations/tanstack-query/root-provider.tsx')
57
- // })
50
+ it ( 'windows' , ( ) => {
51
+ expect (
52
+ relativePath (
53
+ '.\\ src\\main.tsx.ejs ',
54
+ 'src/integrations/tanstack-query/root-provider.tsx' ,
55
+ ) ,
56
+ ) . toBe ( './integrations/tanstack-query/root-provider.tsx' )
57
+ } )
58
58
} )
59
59
60
60
describe ( 'readFileHelper' , ( ) => {
You can’t perform that action at this time.
0 commit comments