1
1
/* @internal */
2
2
namespace ts {
3
- function intOfString ( str : string ) : number {
3
+ function stringToInt ( str : string ) : number {
4
4
const n = parseInt ( str , 10 ) ;
5
5
if ( isNaN ( n ) ) {
6
6
throw new Error ( `Error in parseInt(${ JSON . stringify ( str ) } )` ) ;
@@ -28,10 +28,10 @@ namespace ts {
28
28
// "A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes."
29
29
const rgx = isPrerelease ? / ^ ( \d + ) \. ( \d + ) \. 0 - n e x t .( \d + ) $ / : / ^ ( \d + ) \. ( \d + ) \. ( \d + ) $ / ;
30
30
const match = rgx . exec ( semver ) ;
31
- return match ? new Semver ( intOfString ( match [ 1 ] ) , intOfString ( match [ 2 ] ) , intOfString ( match [ 3 ] ) , isPrerelease ) : undefined ;
31
+ return match ? new Semver ( stringToInt ( match [ 1 ] ) , stringToInt ( match [ 2 ] ) , stringToInt ( match [ 3 ] ) , isPrerelease ) : undefined ;
32
32
}
33
33
34
- constructor (
34
+ private constructor (
35
35
readonly major : number , readonly minor : number , readonly patch : number ,
36
36
/**
37
37
* If true, this is `major.minor.0-next.patch`.
@@ -49,7 +49,9 @@ namespace ts {
49
49
50
50
greaterThan ( sem : Semver ) : boolean {
51
51
return this . major > sem . major || this . major === sem . major
52
- && ( this . minor > sem . minor || this . minor === sem . minor && this . patch > sem . patch ) ;
52
+ && ( this . minor > sem . minor || this . minor === sem . minor
53
+ && ( ! this . isPrerelease && sem . isPrerelease || this . isPrerelease === sem . isPrerelease
54
+ && this . patch > sem . patch ) ) ;
53
55
}
54
56
}
55
57
}
0 commit comments