Skip to content

A few invalid "test" packages in the registry #1

@pdehaan

Description

@pdehaan

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). 🤷

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions