File tree Expand file tree Collapse file tree 1 file changed +2
-24
lines changed Expand file tree Collapse file tree 1 file changed +2
-24
lines changed Original file line number Diff line number Diff line change 1
1
import * as https from "https" ;
2
2
3
- export const compareVersions = ( a : string , b : string ) : number | undefined => {
4
- if ( a === b ) {
5
- return 0 ;
6
- }
7
- const regEx = / [ ^ 0 - 9 . ] / g;
8
- const aSplit = a . replace ( regEx , "" ) . split ( "." ) ;
9
- const bSplit = b . replace ( regEx , "" ) . split ( "." ) ;
10
- const dist = Math . max ( aSplit . length , bSplit . length ) ;
11
- for ( let i = 0 ; i < dist ; i ++ ) {
12
- const aVal = parseInt ( aSplit [ i ] , 10 ) ;
13
- const bVal = parseInt ( bSplit [ i ] , 10 ) ;
14
- if ( aVal > bVal || isNaN ( bVal ) ) {
15
- return 1 ;
16
- }
17
- if ( aVal < bVal || isNaN ( aVal ) ) {
18
- return - 1 ;
19
- }
20
- }
21
- } ;
22
-
23
3
export const getRecentRelease = ( ) : Promise < string > => {
24
4
return new Promise < string > ( ( resolve , reject ) :void => {
25
- const options = {
5
+ https . get ( {
26
6
host : "api.github.com" ,
27
7
path : "/repos/codercom/code-server/releases/latest" ,
28
8
method : "GET" ,
29
9
agent : false ,
30
10
headers : {
31
11
"User-Agent" : "code-server" ,
32
12
} ,
33
- } ;
34
-
35
- https . get ( options , ( res ) => {
13
+ } , ( res ) => {
36
14
if ( res . statusCode !== 200 ) {
37
15
reject ( Error ( "Failed to acquire release information" ) ) ;
38
16
}
You can’t perform that action at this time.
0 commit comments