remove: reject

This commit is contained in:
peaceiris
2019-09-16 05:59:37 +09:00
parent 48daa44ee9
commit baeba7a8a7

View File

@@ -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}`);
}
};
});