@@ -45,6 +45,24 @@ describe('toWin32Path', () => {
45
45
assert . ok ( execFileSyncStub . notCalled ) ;
46
46
} ) ;
47
47
} )
48
+
49
+ describe ( 'when wslpath is not available' , ( ) => {
50
+ beforeEach ( ( ) => execFileSyncStub . throws ( new Error ( 'oh noes!' ) ) ) ;
51
+
52
+ it ( 'falls back to the toWinDirFormat method' , ( ) => {
53
+ const wsl = '/mnt/c/Users/user1/AppData/' ;
54
+ const windows = 'C:\\Users\\user1\\AppData\\' ;
55
+
56
+ assert . strictEqual ( toWin32Path ( wsl ) , windows ) ;
57
+ } ) ;
58
+
59
+ it ( 'supports the drive letter not being C' , ( ) => {
60
+ const wsl = '/mnt/d/Users/user1/AppData' ;
61
+ const windows = 'D:\\Users\\user1\\AppData' ;
62
+
63
+ assert . strictEqual ( toWin32Path ( wsl ) , windows ) ;
64
+ } )
65
+ } ) ;
48
66
} )
49
67
50
68
describe ( 'toWSLPath' , ( ) => {
@@ -53,15 +71,26 @@ describe('toWSLPath', () => {
53
71
it ( 'calls wslpath -u' , ( ) => {
54
72
execFileSyncStub . returns ( asBuffer ( '' ) ) ;
55
73
56
- toWSLPath ( '' ) ;
74
+ toWSLPath ( '' , '' ) ;
57
75
58
76
assert . ok ( execFileSyncStub . calledWith ( 'wslpath' , [ '-u' , '' ] ) ) ;
59
77
} )
60
78
61
79
it ( 'trims off the trailing newline' , ( ) => {
62
80
execFileSyncStub . returns ( asBuffer ( 'the-path\n' ) ) ;
63
81
64
- assert . strictEqual ( toWSLPath ( '' ) , 'the-path' ) ;
82
+ assert . strictEqual ( toWSLPath ( '' , '' ) , 'the-path' ) ;
83
+ } )
84
+
85
+ describe ( 'when wslpath is not available' , ( ) => {
86
+ beforeEach ( ( ) => execFileSyncStub . throws ( new Error ( 'oh noes!' ) ) ) ;
87
+
88
+ it ( 'uses the fallback path' , ( ) => {
89
+ assert . strictEqual (
90
+ toWSLPath ( 'C:/Program Files' , '/mnt/c/Program Files' ) ,
91
+ '/mnt/c/Program Files'
92
+ ) ;
93
+ } )
65
94
} )
66
95
} )
67
96
@@ -76,4 +105,15 @@ describe('getWSLLocalAppDataPath', () => {
76
105
assert . strictEqual ( getWSLLocalAppDataPath ( path ) , '/c/folder/' ) ;
77
106
assert . ok ( execFileSyncStub . calledWith ( 'wslpath' , [ '-u' , 'c:\\Users\\user1\\AppData\\Local' ] ) ) ;
78
107
} ) ;
108
+
109
+ describe ( 'when wslpath is not available' , ( ) => {
110
+ beforeEach ( ( ) => execFileSyncStub . throws ( new Error ( 'oh noes!' ) ) ) ;
111
+
112
+ it ( 'falls back to the getLocalAppDataPath method' , ( ) => {
113
+ const path = '/mnt/c/Users/user1/.bin:/mnt/c/Users/user1:/mnt/c/Users/user1/AppData/' ;
114
+ const appDataPath = '/mnt/c/Users/user1/AppData/Local' ;
115
+
116
+ assert . strictEqual ( getWSLLocalAppDataPath ( path ) , appDataPath ) ;
117
+ } ) ;
118
+ } ) ;
79
119
} ) ;
0 commit comments