Files: 87a18d60fcaae01360adeb9e6283861b864b5cef / lib / latest-update.js
819 bytesRaw
1 | var https = require('https') |
2 | var packageInfo = require('../package.json') |
3 | var compareVersion = require('compare-version') |
4 | var Value = require('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/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