From e72d73212c4f93f3559fe035dd2debdb3f3c9a58 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Tue, 9 Jan 2018 20:51:20 -0800 Subject: [PATCH] omit numerical package names --- package.json | 1 + script/build | 9 +++++++-- test/index.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e2830ec55..4b9cb7af8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/script/build b/script/build index f11416149..d1ba54f1d 100755 --- a/script/build +++ b/script/build @@ -17,7 +17,7 @@ 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() @@ -25,7 +25,12 @@ function addPackage (pkg) { 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() diff --git a/test/index.js b/test/index.js index 09197b824..b09cbc848 100644 --- a/test/index.js +++ b/test/index.js @@ -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() })