Skip to content

Commit 8c65b47

Browse files
authored
Fix cross-platform joinPath behavior (#145)
1 parent 9c9e57d commit 8c65b47

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/utils/file-system.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export class FileSystemUtils {
5656
const normalizedSegments = this.normalizeSegments(segments);
5757

5858
if (this.isWindowsBasePath(basePath)) {
59+
const normalizedBasePath = path.win32.normalize(basePath);
5960
return normalizedSegments.length
60-
? path.win32.join(basePath, ...normalizedSegments)
61-
: path.win32.normalize(basePath);
61+
? path.win32.join(normalizedBasePath, ...normalizedSegments)
62+
: normalizedBasePath;
6263
}
6364

65+
const posixBasePath = basePath.replace(/\\/g, '/');
66+
6467
return normalizedSegments.length
65-
? path.join(basePath, ...normalizedSegments)
66-
: path.join(basePath);
68+
? path.posix.join(posixBasePath, ...normalizedSegments)
69+
: path.posix.normalize(posixBasePath);
6770
}
6871

6972
static async createDirectory(dirPath: string): Promise<void> {

0 commit comments

Comments
 (0)