@@ -2,21 +2,22 @@ import { MacCodacyCli } from './MacCodacyCli'
22
33export class WinWSLCodacyCli extends MacCodacyCli {
44 constructor ( rootPath : string , provider ?: string , organization ?: string , repository ?: string ) {
5- const winRootPath = rootPath . startsWith ( '/mnt/' ) ? WinWSLCodacyCli . fromWSLPath ( rootPath ) : rootPath
5+ const winRootPath =
6+ rootPath . startsWith ( '/mnt/' ) || rootPath . startsWith ( "'/mnt/" ) ? WinWSLCodacyCli . fromWSLPath ( rootPath ) : rootPath
67 super ( winRootPath , provider , organization , repository )
78 }
89
910 private static toWSLPath ( path : string ) : string {
1011 // Convert Windows path to WSL path
11- // Example: C:\Users\user\project -> /mnt/c/Users/user/project
12- const wslPath = path . replace ( / \\ / g, '/' ) . replace ( / ^ ( [ a - z A - Z ] ) : / , '/mnt/$1' )
12+ // Example: ' C:\Users\user\project' -> ' /mnt/c/Users/user/project'
13+ const wslPath = path . replace ( / \\ / g, '/' ) . replace ( / ^ ' ( [ a - z A - Z ] ) : / , " '/mnt/$1" )
1314 return wslPath
1415 }
1516
1617 private static fromWSLPath ( path : string ) : string {
17- // Convert WSL path to Windows path
18- // Example: /mnt/c/Users/user/project -> C:\Users\user\project
19- const windowsPath = path . replace ( / ^ \/ m n t \/ ( [ a - z A - Z ] ) / , '$1:' ) . replace ( / \/ / g, '\\' )
18+ // Convert WSL path to Windows path while keeping quotes
19+ // Example: ' /mnt/c/Users/user/project' -> ' C:\Users\user\project'
20+ const windowsPath = path . replace ( / ^ ' \/ m n t \/ ( [ a - z A - Z ] ) / , " '$1:" ) . replace ( / \/ / g, '\\' )
2021 return windowsPath
2122 }
2223
0 commit comments