1
0
mirror of https://github.com/mgerb/ps-launcher synced 2026-01-11 02:52:49 +00:00

poll github for new releases - closes #6

This commit is contained in:
2017-10-29 14:01:24 -05:00
parent 9806b8ebe6
commit f39901ca70
7 changed files with 94 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
import axios from 'axios';
import * as _ from 'lodash';
class Versioning {
private readonly releaseEndPoint: string = 'https://api.github.com/repos/mgerb/ps-launcher/releases';
public async checkForUpdates(): Promise<boolean> {
const res = await axios.get(this.releaseEndPoint);
return !!_.find(res.data, (release: any) => {
return this.parseVersion(release.tag_name) > this.parseVersion(VERSION);
});
}
/**
* returns a number value for a version string matching '0.0.1'
* @param {string} version
* @returns {*}
* @memberof Versioning
*/
public parseVersion(version: string): number {
const parts = version.split('.');
return _.sumBy(parts, p => parseInt(p, 10));
}
}
export const versioning = new Versioning();