git ssb

10+

Matt McKegg / patchwork



Tree: f8d403078d632490a3a821d929fa54b0f9673a6c

Files: f8d403078d632490a3a821d929fa54b0f9673a6c / lib / latest-update.js

819 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/ssbc/patchwork/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