git ssb

10+

Matt McKegg / patchwork



Tree: cd963a73cebd5ce97b4fddb47ade2fd905c27019

Files: cd963a73cebd5ce97b4fddb47ade2fd905c27019 / lib / latest-update.js

827 bytesRaw
1var https = require('https')
2var packageInfo = require('../package.json')
3var compareVersion = require('compare-version')
4var Value = require('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/patchwork-next/releases/latest',
13 headers: {
14 'user-agent': `Patchwork 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