Add a really simple and stupid way to check if you are running the latest version.

This commit is contained in:
Godzil
2018-06-11 22:37:15 +01:00
parent 7f2f983f55
commit bb70161652
3 changed files with 217 additions and 190 deletions

View File

@@ -1,5 +1,26 @@
'use strict';
import batch from './batch';
import request = require('request');
import log = require('./log');
import pjson = require('pjson');
const current_version = pjson.version;
/* Check if the current version is the latest */
log.info('Crunchy version ' + current_version);
request.get({ uri: 'https://raw.githubusercontent.com/Godzil/Crunchy/master/package.json' },
(error: Error, response: any, body: any) =>
{
const onlinepkg = JSON.parse(body);
let tmp = current_version.split('.');
const cur = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
tmp = onlinepkg.version.split('.');
const dist = (Number(tmp[0]) * 10000) + (Number(tmp[1]) * 100) + Number(tmp[2]);
if (dist > cur)
{
log.warn('There is a newer version of crunchy (v' + onlinepkg.version + '), you should update!');
}
});
batch(process.argv, (err: any) =>
{