Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.js to automatically fetch the latest version name with github api #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
document.addEventListener('DOMContentLoaded', function () {
document.addEventListener('DOMContentLoaded', async function () {

// rather than looking for it all the time, you could just create an enum and change this once than updating every line
const github = {
repo: 'https://github.com/lapce/lapce',
version: 'v0.2.7',
version: (await (await fetch("https://api.github.com/repos/lapce/lapce/releases/latest")).json()).name,
windows: 'Lapce-windows.msi',
linux: 'Lapce-linux.tar.gz',
macos: 'Lapce-macos.dmg'
Expand Down Expand Up @@ -83,4 +83,4 @@ document.addEventListener('DOMContentLoaded', function () {
download.setAttribute("href", `${github.repo}/releases/download/${github.version}/${github.linux}`)
break;
}
});
});