@@ -25,8 +25,11 @@ describe('find-visualstudio', function () {
25
25
it ( 'VS2013' , async function ( ) {
26
26
const finder = new TestVisualStudioFinder ( semverV1 , null )
27
27
28
- finder . findVisualStudio2017OrNewer = async ( ) => {
29
- return finder . parseData ( new Error ( ) , '' , '' )
28
+ finder . findVisualStudio2017 = async ( ) => {
29
+ return finder . parseData ( new Error ( ) , '' , '' , [ 2017 ] )
30
+ }
31
+ finder . findVisualStudio2019OrNewer = async ( ) => {
32
+ return finder . parseData ( new Error ( ) , '' , '' , [ 2019 , 2022 ] )
30
33
}
31
34
finder . regSearchKeys = async ( keys , value , addOpts ) => {
32
35
for ( let i = 0 ; i < keys . length ; ++ i ) {
@@ -69,10 +72,15 @@ describe('find-visualstudio', function () {
69
72
patch : 0
70
73
} , null )
71
74
72
- finder . findVisualStudio2017OrNewer = async ( ) => {
75
+ finder . findVisualStudio2017 = async ( ) => {
73
76
const file = path . join ( __dirname , 'fixtures' , 'VS_2017_Unusable.txt' )
74
77
const data = fs . readFileSync ( file )
75
- return finder . parseData ( null , data , '' )
78
+ return finder . parseData ( null , data , '' , [ 2017 ] )
79
+ }
80
+ finder . findVisualStudio2019OrNewer = async ( ) => {
81
+ const file = path . join ( __dirname , 'fixtures' , 'VS_2017_Unusable.txt' )
82
+ const data = fs . readFileSync ( file )
83
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
76
84
}
77
85
finder . regSearchKeys = async ( keys , value , addOpts ) => {
78
86
for ( let i = 0 ; i < keys . length ; ++ i ) {
@@ -96,8 +104,11 @@ describe('find-visualstudio', function () {
96
104
it ( 'VS2015' , async function ( ) {
97
105
const finder = new TestVisualStudioFinder ( semverV1 , null )
98
106
99
- finder . findVisualStudio2017OrNewer = async ( ) => {
100
- return finder . parseData ( new Error ( ) , '' , '' )
107
+ finder . findVisualStudio2017 = async ( ) => {
108
+ return finder . parseData ( new Error ( ) , '' , '' , [ 2017 ] )
109
+ }
110
+ finder . findVisualStudio2019OrNewer = async ( ) => {
111
+ return finder . parseData ( new Error ( ) , '' , '' , [ 2019 , 2022 ] )
101
112
}
102
113
finder . regSearchKeys = async ( keys , value , addOpts ) => {
103
114
for ( let i = 0 ; i < keys . length ; ++ i ) {
@@ -132,7 +143,7 @@ describe('find-visualstudio', function () {
132
143
it ( 'error from PowerShell' , async function ( ) {
133
144
const finder = new TestVisualStudioFinder ( semverV1 , null , null )
134
145
135
- finder . parseData ( new Error ( ) , '' , '' , ( info ) => {
146
+ finder . parseData ( new Error ( ) , '' , '' , [ ] , ( info ) => {
136
147
assert . ok ( / u s e P o w e r S h e l l / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
137
148
assert . ok ( ! info , 'no data' )
138
149
} )
@@ -141,7 +152,7 @@ describe('find-visualstudio', function () {
141
152
it ( 'empty output from PowerShell' , async function ( ) {
142
153
const finder = new TestVisualStudioFinder ( semverV1 , null , null )
143
154
144
- finder . parseData ( null , '' , '' , ( info ) => {
155
+ finder . parseData ( null , '' , '' , [ ] , ( info ) => {
145
156
assert . ok ( / u s e P o w e r S h e l l / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
146
157
assert . ok ( ! info , 'no data' )
147
158
} )
@@ -150,7 +161,7 @@ describe('find-visualstudio', function () {
150
161
it ( 'output from PowerShell not JSON' , async function ( ) {
151
162
const finder = new TestVisualStudioFinder ( semverV1 , null , null )
152
163
153
- finder . parseData ( null , 'AAAABBBB' , '' , ( info ) => {
164
+ finder . parseData ( null , 'AAAABBBB' , '' , [ ] , ( info ) => {
154
165
assert . ok ( / u s e P o w e r S h e l l / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
155
166
assert . ok ( ! info , 'no data' )
156
167
} )
@@ -159,7 +170,7 @@ describe('find-visualstudio', function () {
159
170
it ( 'wrong JSON from PowerShell' , async function ( ) {
160
171
const finder = new TestVisualStudioFinder ( semverV1 , null , null )
161
172
162
- finder . parseData ( null , '{}' , '' , ( info ) => {
173
+ finder . parseData ( null , '{}' , '' , [ ] , ( info ) => {
163
174
assert . ok ( / u s e P o w e r S h e l l / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
164
175
assert . ok ( ! info , 'no data' )
165
176
} )
@@ -168,7 +179,7 @@ describe('find-visualstudio', function () {
168
179
it ( 'empty JSON from PowerShell' , async function ( ) {
169
180
const finder = new TestVisualStudioFinder ( semverV1 , null , null )
170
181
171
- finder . parseData ( null , '[]' , '' , ( info ) => {
182
+ finder . parseData ( null , '[]' , '' , [ ] , ( info ) => {
172
183
assert . ok ( / f i n d .* V i s u a l S t u d i o / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
173
184
assert . ok ( ! info , 'no data' )
174
185
} )
@@ -185,7 +196,7 @@ describe('find-visualstudio', function () {
185
196
] ,
186
197
path : 'C:\\VS' ,
187
198
version : '9999.9999.9999.9999'
188
- } ] ) , '' , ( info ) => {
199
+ } ] ) , '' , [ 2017 , 2019 , 2022 ] , ( info ) => {
189
200
assert . ok ( / u n k n o w n v e r s i o n / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
190
201
assert . ok ( / f i n d .* V i s u a l S t u d i o / i. test ( finder . errorLog [ 1 ] ) , 'expect error' )
191
202
assert . ok ( ! info , 'no data' )
@@ -197,7 +208,7 @@ describe('find-visualstudio', function () {
197
208
198
209
const file = path . join ( __dirname , 'fixtures' , 'VS_2017_Unusable.txt' )
199
210
const data = fs . readFileSync ( file )
200
- finder . parseData ( null , data , '' , ( info ) => {
211
+ finder . parseData ( null , data , '' , [ 2017 , 2019 , 2022 ] , ( info ) => {
201
212
assert . ok ( / c h e c k i n g / i. test ( finder . errorLog [ 0 ] ) , 'expect error' )
202
213
assert . ok ( / f i n d .* V i s u a l S t u d i o / i. test ( finder . errorLog [ 2 ] ) , 'expect error' )
203
214
assert . ok ( ! info , 'no data' )
@@ -208,11 +219,17 @@ describe('find-visualstudio', function () {
208
219
const finder = new TestVisualStudioFinder ( semverV1 , null )
209
220
210
221
poison ( finder , 'regSearchKeys' )
211
- finder . findVisualStudio2017OrNewer = async ( ) => {
222
+ finder . findVisualStudio2017 = async ( ) => {
212
223
const file = path . join ( __dirname , 'fixtures' ,
213
224
'VS_2017_BuildTools_minimal.txt' )
214
225
const data = fs . readFileSync ( file )
215
- return finder . parseData ( null , data , '' )
226
+ return finder . parseData ( null , data , '' , [ 2017 ] )
227
+ }
228
+ finder . findVisualStudio2019OrNewer = async ( ) => {
229
+ const file = path . join ( __dirname , 'fixtures' ,
230
+ 'VS_2017_BuildTools_minimal.txt' )
231
+ const data = fs . readFileSync ( file )
232
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
216
233
}
217
234
const { err, info } = await finder . findVisualStudio ( )
218
235
assert . strictEqual ( err , null )
@@ -234,11 +251,17 @@ describe('find-visualstudio', function () {
234
251
const finder = new TestVisualStudioFinder ( semverV1 , null )
235
252
236
253
poison ( finder , 'regSearchKeys' )
237
- finder . findVisualStudio2017OrNewer = async ( ) => {
254
+ finder . findVisualStudio2017 = async ( ) => {
238
255
const file = path . join ( __dirname , 'fixtures' ,
239
256
'VS_2017_Community_workload.txt' )
240
257
const data = fs . readFileSync ( file )
241
- return finder . parseData ( null , data , '' )
258
+ return finder . parseData ( null , data , '' , [ 2017 ] )
259
+ }
260
+ finder . findVisualStudio2019OrNewer = async ( ) => {
261
+ const file = path . join ( __dirname , 'fixtures' ,
262
+ 'VS_2017_Community_workload.txt' )
263
+ const data = fs . readFileSync ( file )
264
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
242
265
}
243
266
const { err, info } = await finder . findVisualStudio ( )
244
267
assert . strictEqual ( err , null )
@@ -260,10 +283,15 @@ describe('find-visualstudio', function () {
260
283
const finder = new TestVisualStudioFinder ( semverV1 , null )
261
284
262
285
poison ( finder , 'regSearchKeys' )
263
- finder . findVisualStudio2017OrNewer = async ( ) => {
286
+ finder . findVisualStudio2017 = async ( ) => {
264
287
const file = path . join ( __dirname , 'fixtures' , 'VS_2017_Express.txt' )
265
288
const data = fs . readFileSync ( file )
266
- return finder . parseData ( null , data , '' )
289
+ return finder . parseData ( null , data , '' , [ 2017 ] )
290
+ }
291
+ finder . findVisualStudio2019OrNewer = async ( ) => {
292
+ const file = path . join ( __dirname , 'fixtures' , 'VS_2017_Express.txt' )
293
+ const data = fs . readFileSync ( file )
294
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
267
295
}
268
296
const { err, info } = await finder . findVisualStudio ( )
269
297
assert . strictEqual ( err , null )
@@ -285,11 +313,17 @@ describe('find-visualstudio', function () {
285
313
const finder = new TestVisualStudioFinder ( semverV1 , null )
286
314
287
315
poison ( finder , 'regSearchKeys' )
288
- finder . findVisualStudio2017OrNewer = async ( ) => {
316
+ finder . findVisualStudio2017 = async ( ) => {
289
317
const file = path . join ( __dirname , 'fixtures' ,
290
318
'VS_2019_Preview.txt' )
291
319
const data = fs . readFileSync ( file )
292
- return finder . parseData ( null , data , '' )
320
+ return finder . parseData ( null , data , '' , [ 2017 ] )
321
+ }
322
+ finder . findVisualStudio2019OrNewer = async ( ) => {
323
+ const file = path . join ( __dirname , 'fixtures' ,
324
+ 'VS_2019_Preview.txt' )
325
+ const data = fs . readFileSync ( file )
326
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
293
327
}
294
328
const { err, info } = await finder . findVisualStudio ( )
295
329
assert . strictEqual ( err , null )
@@ -311,11 +345,17 @@ describe('find-visualstudio', function () {
311
345
const finder = new TestVisualStudioFinder ( semverV1 , null )
312
346
313
347
poison ( finder , 'regSearchKeys' )
314
- finder . findVisualStudio2017OrNewer = async ( ) => {
348
+ finder . findVisualStudio2017 = async ( ) => {
349
+ const file = path . join ( __dirname , 'fixtures' ,
350
+ 'VS_2019_BuildTools_minimal.txt' )
351
+ const data = fs . readFileSync ( file )
352
+ return finder . parseData ( null , data , '' , [ 2017 ] )
353
+ }
354
+ finder . findVisualStudio2019OrNewer = async ( ) => {
315
355
const file = path . join ( __dirname , 'fixtures' ,
316
356
'VS_2019_BuildTools_minimal.txt' )
317
357
const data = fs . readFileSync ( file )
318
- return finder . parseData ( null , data , '' )
358
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
319
359
}
320
360
const { err, info } = await finder . findVisualStudio ( )
321
361
assert . strictEqual ( err , null )
@@ -337,11 +377,17 @@ describe('find-visualstudio', function () {
337
377
const finder = new TestVisualStudioFinder ( semverV1 , null )
338
378
339
379
poison ( finder , 'regSearchKeys' )
340
- finder . findVisualStudio2017OrNewer = async ( ) => {
380
+ finder . findVisualStudio2017 = async ( ) => {
381
+ const file = path . join ( __dirname , 'fixtures' ,
382
+ 'VS_2019_Community_workload.txt' )
383
+ const data = fs . readFileSync ( file )
384
+ return finder . parseData ( null , data , '' , [ 2017 ] )
385
+ }
386
+ finder . findVisualStudio2019OrNewer = async ( ) => {
341
387
const file = path . join ( __dirname , 'fixtures' ,
342
388
'VS_2019_Community_workload.txt' )
343
389
const data = fs . readFileSync ( file )
344
- return finder . parseData ( null , data , '' )
390
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
345
391
}
346
392
const { err, info } = await finder . findVisualStudio ( )
347
393
assert . strictEqual ( err , null )
@@ -372,11 +418,17 @@ describe('find-visualstudio', function () {
372
418
finder . msBuildPathExists = ( path ) => {
373
419
return true
374
420
}
375
- finder . findVisualStudio2017OrNewer = async ( ) => {
421
+ finder . findVisualStudio2017 = async ( ) => {
376
422
const file = path . join ( __dirname , 'fixtures' ,
377
423
'VS_2022_Community_workload.txt' )
378
424
const data = fs . readFileSync ( file )
379
- return finder . parseData ( null , data , '' )
425
+ return finder . parseData ( null , data , '' , [ 2017 ] )
426
+ }
427
+ finder . findVisualStudio2019OrNewer = async ( ) => {
428
+ const file = path . join ( __dirname , 'fixtures' ,
429
+ 'VS_2022_Community_workload.txt' )
430
+ const data = fs . readFileSync ( file )
431
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
380
432
}
381
433
const { err, info } = await finder . findVisualStudio ( )
382
434
assert . strictEqual ( err , null )
@@ -394,7 +446,7 @@ describe('find-visualstudio', function () {
394
446
} )
395
447
396
448
function allVsVersions ( finder ) {
397
- finder . findVisualStudio2017OrNewer = async ( ) => {
449
+ finder . findVisualStudio2017 = async ( ) => {
398
450
const data0 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
399
451
'VS_2017_Unusable.txt' ) ) )
400
452
const data1 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
@@ -403,17 +455,20 @@ describe('find-visualstudio', function () {
403
455
'VS_2017_Community_workload.txt' ) ) )
404
456
const data3 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
405
457
'VS_2017_Express.txt' ) ) )
406
- const data4 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
458
+ const data = JSON . stringify ( data0 . concat ( data1 , data2 , data3 ) )
459
+ return finder . parseData ( null , data , '' , [ 2017 ] )
460
+ }
461
+ finder . findVisualStudio2019OrNewer = async ( ) => {
462
+ const data0 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
407
463
'VS_2019_Preview.txt' ) ) )
408
- const data5 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
464
+ const data1 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
409
465
'VS_2019_BuildTools_minimal.txt' ) ) )
410
- const data6 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
466
+ const data2 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
411
467
'VS_2019_Community_workload.txt' ) ) )
412
- const data7 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
468
+ const data3 = JSON . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' ,
413
469
'VS_2022_Community_workload.txt' ) ) )
414
- const data = JSON . stringify ( data0 . concat ( data1 , data2 , data3 , data4 ,
415
- data5 , data6 , data7 ) )
416
- return finder . parseData ( null , data , '' )
470
+ const data = JSON . stringify ( data0 . concat ( data1 , data2 , data3 ) )
471
+ return finder . parseData ( null , data , '' , [ 2019 , 2022 ] )
417
472
}
418
473
finder . regSearchKeys = async ( keys , value , addOpts ) => {
419
474
for ( let i = 0 ; i < keys . length ; ++ i ) {
0 commit comments