Last active
February 4, 2020 12:32
-
-
Save felixheck/c51856daa8e1cf05987dbb095b87b8c4 to your computer and use it in GitHub Desktop.
List all projects with hapi dependencies to be scoped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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