mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-24 20:12:15 +01:00
remove: reject
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
||||||
|
|
||||||
function getLatestVersion() {
|
function getLatestVersion() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
// if (typeof milliseconds !== "number") {
|
|
||||||
// throw new Error("milleseconds not a number");
|
|
||||||
// }
|
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
||||||
xhr.open("GET", url);
|
xhr.open("GET", url);
|
||||||
@@ -18,8 +14,9 @@ function getLatestVersion() {
|
|||||||
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
||||||
|
|
||||||
resolve(latestVersion);
|
resolve(latestVersion);
|
||||||
} else if (xhr.status !== 200) {
|
} else {
|
||||||
reject(`ERROR: got status ${xhr.status}`);
|
throw new Error(`ERROR: got status ${xhr.status}`);
|
||||||
|
// reject(`ERROR: got status ${xhr.status}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user