Skip to content

Commit

Permalink
Merge pull request #9 from nice-registry/omit-numerical-package-names
Browse files Browse the repository at this point in the history
omit numerical package names
  • Loading branch information
zeke authored Jan 10, 2018
2 parents b0decf7 + e72d732 commit 0f0447b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"license": "MIT",
"devDependencies": {
"dependent-counts": "^2.0.0",
"is-number": "^4.0.0",
"lodash": "^3.10.0",
"ora": "^0.4.0",
"package-stream": "^1.0.2",
Expand Down
9 changes: 7 additions & 2 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ registry

function addPackage (pkg) {
const name = pkg.name
if (name && name.length && !names.includes(name)) names.push(name)
if (name && name.length) names.push(name)

// to check the finish function early...
// if (names.length > 100 * 1000) finish()
}

function finish () {
const filename = path.join(__dirname, '../names.json')
const finalNames = chain(names).compact().uniq().value()
const finalNames = chain(names)
.compact()
.uniq()
.value()
.filter(name => !isNumber(name))

fs.writeFileSync(filename, JSON.stringify(finalNames, null, 2))
console.log(`\nwrote ${finalNames.length} package names to ${filename}`)
process.exit()
Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const names = require('..')
test('names', function (t) {
t.ok(Array.isArray(names), 'is an array')
t.ok(names.length > 260*1000, 'has hella names')
t.notOk(names.find(name => name === '69'), 'does not include numerical packages')
t.end()
})

0 comments on commit 0f0447b

Please sign in to comment.