git ssb

5+

Matt McKegg / ferment



Tree: ce8c9a23510ffcaae086aac41d0d04be17ab0af0

Files: ce8c9a23510ffcaae086aac41d0d04be17ab0af0 / lib / latest-update.js

827 bytesRaw
1var https = require('https')
2var packageInfo = require('../package.json')
3var compareVersion = require('compare-version')
4var Value = require('@mmckegg/mutant/value')
5
6module.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