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