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 {
3737}
3838
3939export 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
4146 const cleanedTo = to . startsWith ( './' ) ? to . slice ( 2 ) : to
4247
48+ const fromSegments = cleanedFrom . split ( '/' )
49+ const toSegments = cleanedTo . split ( '/' )
50+
4351 if ( process . env . CTA_DEBUG ) {
52+ console . log ( 'process.platform' , process . platform )
53+ console . log ( 'fixedOnWindows' , fixedOnWindows )
4454 console . log ( 'from' , from )
4555 console . log ( 'to' , to )
4656 console . log ( 'cleanedFrom' , cleanedFrom )
4757 console . log ( 'cleanedTo' , cleanedTo )
4858 }
4959
50- const fromSegments = cleanedFrom . split ( '/' )
51- const toSegments = cleanedTo . split ( '/' )
52-
5360 fromSegments . pop ( )
5461 toSegments . pop ( )
5562
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ describe('relativePath', () => {
4747 ) ,
4848 ) . toBe ( '../integrations/tanstack-query/layout.tsx' )
4949 } )
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+ } )
5858} )
5959
6060describe ( 'readFileHelper' , ( ) => {
You can’t perform that action at this time.
0 commit comments