Skip to content

Instantly share code, notes, and snippets.

@felixheck
Last active February 4, 2020 12:32
Show Gist options
  • Save felixheck/c51856daa8e1cf05987dbb095b87b8c4 to your computer and use it in GitHub Desktop.
Save felixheck/c51856daa8e1cf05987dbb095b87b8c4 to your computer and use it in GitHub Desktop.
List all projects with hapi dependencies to be scoped
const glob = require('fast-glob');
const info = require( 'npm-registry-package-info' );
const paths = glob.sync('**/package.json', {
ignore: ['**/node_modules/**/package.json'],
deep: 5
});
paths.forEach(path => {
const { dependencies, devDependencies, peerDependencies } = require(`${process.cwd()}/${path}`);
const moduleNames = Object.keys({...dependencies, ...devDependencies, ...peerDependencies});
const packages = [].concat(...moduleNames).map(x => `@hapi/${x}`);
if (!packages.length) return;
info({ packages }, (err, { data } = { data: {} }) => {
if (err) throw err;
if (!data) return;
const exists = Object.keys(data);
if (exists.length) {
console.log([path, ...exists].join('\n\t'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment