-
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathoutdated.mjs
More file actions
25 lines (21 loc) · 706 Bytes
/
outdated.mjs
File metadata and controls
25 lines (21 loc) · 706 Bytes
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
#!/usr/bin/env zx
/* globals $, chalk, process */
const lines = $.sync`cat src/lib/presets.js`.stdout
.split('\n')
.filter((i) => i.includes('jsdelivr('))
.map((i) => i.split(`'`)[1])
let outdated = false
for (const line of lines) {
const p = line.split('@')
const name = p[0] || '@' + p[1]
const version = parseInt((p[0] ? p[1] : p[2]).split('/')[0])
const latest = $.sync`npm view ${name}`.stdout.split('\n').filter((i) => i.includes('latest:'))[0]
const major = parseInt(latest.split(' ')[1].split('.')[0])
if (version === major) {
console.log(chalk.green(line, 'OK'))
} else {
console.log(chalk.red(line, latest))
outdated = true
}
}
if (outdated) process.exit(1)