1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 18:32:34 +01:00
lossless-cut/public/update-checker.js

33 lines
1000 B
JavaScript
Raw Normal View History

2018-02-17 15:15:30 +01:00
const GitHub = require('github-api');
2020-03-04 11:41:40 +01:00
// eslint-disable-next-line import/no-extraneous-dependencies
2018-02-17 15:15:30 +01:00
const electron = require('electron');
2018-09-30 22:08:36 +02:00
const { app } = electron;
2018-02-17 15:15:30 +01:00
const gh = new GitHub();
const repo = gh.getRepo('mifi', 'lossless-cut');
async function checkNewVersion() {
try {
// From API: https://developer.github.com/v3/repos/releases/#get-the-latest-release
// View the latest published full release for the repository.
// Draft releases and prereleases are not returned by this endpoint.
2018-02-17 15:15:30 +01:00
const res = (await repo.getRelease('latest')).data;
const tagName = res.tag_name;
const currentVersion = app.getVersion();
// const currentVersion = '1.8.0';
2019-11-04 12:29:56 +01:00
console.log('Current version', currentVersion);
console.log('Newest version', tagName);
2018-02-17 15:15:30 +01:00
if (tagName !== `v${currentVersion}`) return tagName;
return undefined;
} catch (e) {
console.error('Failed to check github version');
return undefined;
}
}
module.exports = { checkNewVersion };