Skip to content

Commit c0c3599

Browse files
author
John McCambridge
committed
Move request options object into the options parameter, rename rej
1 parent 27fabef commit c0c3599

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

packages/server/src/updater.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
11
import * as https from "https";
22

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-
233
export const getRecentRelease = (): Promise<string> => {
244
return new Promise<string>((resolve, reject):void => {
25-
const options = {
5+
https.get({
266
host: "api.github.com",
277
path: "/repos/codercom/code-server/releases/latest",
288
method: "GET",
299
agent: false,
3010
headers: {
3111
"User-Agent": "code-server",
3212
},
33-
};
34-
35-
https.get(options, (res) => {
13+
}, (res) => {
3614
if (res.statusCode !== 200) {
3715
reject(Error("Failed to acquire release information"));
3816
}

0 commit comments

Comments
 (0)