refactor: Get latest version via homebrew
This commit is contained in:
parent
85171ece4e
commit
b55f5ebfde
1 changed files with 2 additions and 4 deletions
|
|
@ -4,16 +4,14 @@ function getLatestVersion() {
|
|||
// return new Promise((resolve, reject) => {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
||||
const url = "https://formulae.brew.sh/api/formula/hugo.json";
|
||||
xhr.open("GET", url);
|
||||
xhr.send();
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
const result = JSON.parse(xhr.responseText);
|
||||
const latestURL = result["assets"][0].browser_download_url;
|
||||
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
||||
|
||||
const latestVersion = result.versions.stable;
|
||||
resolve(latestVersion);
|
||||
// } else {
|
||||
// reject(`ERROR: got status ${xhr.status}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue