@@ -351,44 +351,43 @@ nvm_normalize_semver() {
351
351
352
352
# convert comparators into required grammar
353
353
local validated_comparator_set
354
- validated_comparator_set=$( command printf " %s " " $comparator_set " \
355
- | command sed -E "
356
- # exactly 1 space is needed before and after every comparator (including the first and last comparators)
357
- s/\011/ /g;s/ +/ /g;
358
-
359
- # normalize all wildcards to x
360
- s/X|\*/x/g;
361
-
362
- # space out numbers surrounding '-'
363
- s/ ?- ?/ - /g;
364
-
365
- # ' 1 ' => ' 1.x.x '
366
- # ' x ' => ' x.x.x '
367
- s/ ([0-9]+|x) / \1.x.x /g;
368
-
369
- # ' 1.2 ' => ' 1.2.x '
370
- # ' 1.x ' => ' 1.x.x '
371
- # ' x.x ' => ' x.x.x '
372
- s/ (([0-9]+|x)\.([0-9]+|x)) / \1.x /g;
373
-
374
- # ' 1.2.3 - 1.2.4 ' => ' >=1.2.3 <=1.2.4 '
375
- s/ (([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) ?\- ?(([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) / >=\1 <=\5 /g;
376
-
377
- # ' > 1.2.3 ' => ' >1.2.3 '
378
- # ' < 1.2.5 ' => ' <1.2.5 '
379
- # ' <= 1.2.3 ' => ' <=1.2.3 '
380
- # ' >= 1.2.3 ' => ' >=1.2.3 '
381
- # ' = 1.2.3 ' => ' =1.2.3 '
382
- # ' ~ 1.2.3 ' => ' ~1.2.3 '
383
- # ' ^ 1.2.3 ' => ' ^1.2.3 '
384
- # ' v 1.2.3 ' => ' v1.2.3 '
385
- s/ (v|<|>|<=|>=|=|~|\^) (([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) / \1\2 /g;
386
-
387
- # ' =1.2.3 ' => ' 1.2.3 '
388
- # ' v1.2.3 ' => ' 1.2.3 '
389
- s/ (=|v)//g;
390
- " \
391
- | command awk ' {
354
+ validated_comparator_set=$( command printf " %s " " $comparator_set " |
355
+ command sed -E "
356
+ # exactly 1 space is needed before and after every comparator (including the first and last comparators)
357
+ s/\011/ /g;s/ +/ /g;
358
+
359
+ # normalize all wildcards to x
360
+ s/X|\*/x/g;
361
+
362
+ # space out numbers surrounding '-'
363
+ s/ ?- ?/ - /g;
364
+
365
+ # ' 1 ' => ' 1.x.x '
366
+ # ' x ' => ' x.x.x '
367
+ s/ ([0-9]+|x) / \1.x.x /g;
368
+
369
+ # ' 1.2 ' => ' 1.2.x '
370
+ # ' 1.x ' => ' 1.x.x '
371
+ # ' x.x ' => ' x.x.x '
372
+ s/ (([0-9]+|x)\.([0-9]+|x)) / \1.x /g;
373
+
374
+ # ' 1.2.3 - 1.2.4 ' => ' >=1.2.3 <=1.2.4 '
375
+ s/ (([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) ?\- ?(([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) / >=\1 <=\5 /g;
376
+
377
+ # ' > 1.2.3 ' => ' >1.2.3 '
378
+ # ' < 1.2.5 ' => ' <1.2.5 '
379
+ # ' <= 1.2.3 ' => ' <=1.2.3 '
380
+ # ' >= 1.2.3 ' => ' >=1.2.3 '
381
+ # ' = 1.2.3 ' => ' =1.2.3 '
382
+ # ' ~ 1.2.3 ' => ' ~1.2.3 '
383
+ # ' ^ 1.2.3 ' => ' ^1.2.3 '
384
+ # ' v 1.2.3 ' => ' v1.2.3 '
385
+ s/ (v|<|>|<=|>=|=|~|\^) (([0-9]+|x)\.([0-9]+|x)\.([0-9]+|x)) / \1\2 /g;
386
+
387
+ # ' =1.2.3 ' => ' 1.2.3 '
388
+ # ' v1.2.3 ' => ' 1.2.3 '
389
+ s/ (=|v)//g;" |
390
+ command awk ' {
392
391
# handle conversions of comparators with ^ or ~ or x into required grammar
393
392
# ` ^0.0.1 ` => ` >=0.0.1 <0.0.2 `
394
393
# ` ^0.1.2 ` => ` >=0.1.2 <0.2.0 `
@@ -462,8 +461,8 @@ nvm_normalize_semver() {
462
461
}
463
462
}
464
463
print output
465
- }' \
466
- | command sed -E ' s/^ +//;s/ +$//'
464
+ }' |
465
+ command sed -E ' s/^ +//;s/ +$//'
467
466
)
468
467
469
468
# only comparator_sets composed of the required grammar are marked as valid
0 commit comments