Skip to content

Commit

Permalink
fix(path): win32 posix path convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Oct 26, 2023
1 parent f800d37 commit 7e1b6d1
Show file tree
Hide file tree
Showing 3 changed files with 1,769 additions and 767 deletions.
8 changes: 5 additions & 3 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {sep} from 'path';
import {posix, sep, win32} from 'path';
import {Platforms} from '../constants';

export function addSlashPrefix(path: string): string {
Expand All @@ -9,15 +9,17 @@ export function addSlashPrefix(path: string): string {

export function convertBackSlashToSlash(path: string): string {
if (process.platform === Platforms.WINDOWS) {
return path.replace(/\\/g, '/');
return path.split(sep).join(posix.sep);
// return path.replace(/\\/gmu, '/');
}

return path;
}

export function convertSlashToWindowsBackSlashes(path: string): string {
if (process.platform === Platforms.WINDOWS) {
return path.replace(/\//g, '\\\\');
return path.split(posix.sep).join(win32.sep);
// return path.replace(/\//gmu, '\\\\');
}

return path;
Expand Down
Loading

0 comments on commit 7e1b6d1

Please sign in to comment.