Files: ce8c9a23510ffcaae086aac41d0d04be17ab0af0 / lib / latest-update.js
827 bytesRaw
1 | var https = require('https') |
2 | var packageInfo = require('../package.json') |
3 | var compareVersion = require('compare-version') |
4 | var Value = require('@mmckegg/mutant/value') |
5 | |
6 | module.exports = function () { |
7 | var update = Value() |
8 | update.sync = Value(false) |
9 | var version = packageInfo.version |
10 | https.get({ |
11 | host: 'api.github.com', |
12 | path: '/repos/mmckegg/ferment/releases/latest', |
13 | headers: { |
14 | 'user-agent': `Ferment v${version}` |
15 | } |
16 | }, function (res) { |
17 | if (res.statusCode === 200) { |
18 | var result = '' |
19 | res.on('data', (x) => { |
20 | result += x |
21 | }).on('end', () => { |
22 | var info = JSON.parse(result) |
23 | if (compareVersion(info.tag_name.slice(1), version) > 0) { |
24 | update.set(info.tag_name.slice(1)) |
25 | } |
26 | update.sync.set(true) |
27 | }) |
28 | } |
29 | }) |
30 | return update |
31 | } |
32 |
Built with git-ssb-web