-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Not sure if valid bug, or if it's your job to be the package sheriff, but I got a couple errors due to my garbage coding, because it turns out now all packages in the npm registry have a name
(go figure).
Steps to reproduce:
const registry = require('all-the-packages');
filterByName(/^eslint-plugin-/i)
.then((packages) => console.log(packages.length))
.catch(err => console.error(err));
function filterByName(name) {
return new Promise((resolve) => {
const packages = [];
registry.on('package', (pkg) => {
if (pkg.name && pkg.name.match(name)) {
packages.push(pkg);
}
if (!pkg.name) {
console.log("DEBUG:", pkg);
}
}).on('end', () => resolve(packages));
});
}
Output:
$ time node index
DEBUG: { dist: { tarball: 'http://registry.npmjs.org/testx2/-/a' },
maintainers: [ { name: 'testx5', email: '[email protected]' } ],
_npmUser: { name: 'testx5', email: '[email protected]' } }
DEBUG: { dist: { tarball: 'http://registry.npmjs.org/zachtestproject2/-/test.tgz' },
maintainers: [ { name: 'zlrenner', email: '[email protected]' } ],
_npmUser: { name: 'zlrenner', email: '[email protected]' } }
DEBUG: { dist:
{ tarball: 'http://registry.npmjs.org/zachtestproject3/-/test.tgz',
_from: 'http://zachrenner.com/test.tgz' },
maintainers: [ { name: 'zlrenner', email: '[email protected]' } ],
_npmUser: { name: 'zlrenner', email: '[email protected]' } }
DEBUG: { dist:
{ tarball: 'http://registry.npmjs.org/zachtestproject4/-/test.tgz',
_from: 'http://zachrenner.com/test.tgz',
_shasum: 'asd' },
maintainers: [ { name: 'zlrenner', email: '[email protected]' } ],
_npmUser: { name: 'zlrenner', email: '[email protected]' } }
346
# node index 51.87s user 1.22s system 100% cpu 52.707 total
Anyways, not sure if you want to emit the package
event only if the pkg.value
in question passes some basic schema (ie: has a name
and version
property). 🤷
zarenner
Metadata
Metadata
Assignees
Labels
No labels