File tree 2 files changed +25
-9
lines changed
2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @fumadocs/cli ' : patch
3
+ ---
4
+
5
+ Fix Windows path problems
Original file line number Diff line number Diff line change @@ -67,21 +67,32 @@ export async function transformReferences(
67
67
}
68
68
}
69
69
70
+ /**
71
+ * Return the import modifier for `sourceFile` to import `referenceFile`
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * toReferencePath('index.ts', 'dir/hello.ts')
76
+ * // should output './dir/hello'
77
+ * ```
78
+ */
70
79
export function toReferencePath (
71
80
sourceFile : string ,
72
81
referenceFile : string ,
73
82
) : string {
74
83
const extname = path . extname ( referenceFile ) ;
75
- const importPath = path . relative (
76
- path . dirname ( sourceFile ) ,
77
- path . join (
78
- path . dirname ( referenceFile ) ,
79
- path . basename (
80
- referenceFile ,
81
- typescriptExtensions . includes ( extname ) ? extname : undefined ,
84
+ const importPath = path
85
+ . relative (
86
+ path . dirname ( sourceFile ) ,
87
+ path . join (
88
+ path . dirname ( referenceFile ) ,
89
+ path . basename (
90
+ referenceFile ,
91
+ typescriptExtensions . includes ( extname ) ? extname : undefined ,
92
+ ) ,
82
93
) ,
83
- ) ,
84
- ) ;
94
+ )
95
+ . replaceAll ( path . sep , '/' ) ;
85
96
86
97
return importPath . startsWith ( '../' ) ? importPath : `./${ importPath } ` ;
87
98
}
You can’t perform that action at this time.
0 commit comments