-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
check.js
29 lines (26 loc) · 917 Bytes
/
check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { writeFileSync } = require('node:fs')
const { get } = require('node:https')
const pkg = require('./package.json')
get('https://registry.npmjs.org/caniuse-db', res => {
if (res.statusCode < 200 || res.statusCode >= 299) {
process.stderr.write(`${res.statusCode} response from npm\n`)
process.exit(1)
}
let data = ''
res.on('data', chunk => {
data += chunk
})
res.on('end', () => {
let body = JSON.parse(data)
let lastVersion = body['dist-tags'].latest
if (pkg.devDependencies['caniuse-db'] !== lastVersion) {
pkg.version = lastVersion
pkg.devDependencies['caniuse-db'] = lastVersion
writeFileSync('./package.json', `${JSON.stringify(pkg, null, 2)}\n`)
writeFileSync(process.env.GITHUB_OUTPUT, 'newVersion=1\n')
process.stdout.write('caniuse-db has new version\n')
} else {
process.stdout.write('Already up to date\n')
}
})
})