-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollect.js
31 lines (30 loc) · 882 Bytes
/
collect.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
30
31
const registry = require('package-stream')()
const path = require('path')
const fs = require('fs')
const mkdirp = require('mkdirp')
const ora = require('ora')
const spinner = ora().start()
let count = 0
registry
.on('package', function (pkg) {
spinner.text = String(++count)
if (
pkg &&
pkg.name &&
pkg.description &&
(
pkg.name.toLowerCase().replace(/[\._-]/g, ' ').split(' ').includes('nock') ||
pkg.description.toLowerCase().split(' ').includes('nock') ||
(pkg.dependencies && pkg.dependencies.nock)
)
) {
const file = path.join(__dirname, `packages/${pkg.name}.json`)
mkdirp(path.dirname(file))
fs.writeFileSync(file, JSON.stringify(pkg))
console.log()
console.log([pkg.name, pkg.description].join(' - '))
}
})
.on('up-to-date', function () {
process.exit()
})