2019-09-25 14:01:10 +02:00
|
|
|
// This script lists all dependencies that have package install scripts
|
|
|
|
const path = require('path')
|
|
|
|
const readInstalled = require('read-installed')
|
|
|
|
|
|
|
|
const installScripts = ['preinstall', 'install', 'postinstall']
|
|
|
|
|
|
|
|
readInstalled('./', { dev: true }, function (err, data) {
|
2019-11-20 01:03:20 +01:00
|
|
|
if (err) {
|
|
|
|
throw err
|
|
|
|
}
|
2019-09-25 14:01:10 +02:00
|
|
|
|
|
|
|
const deps = data.dependencies
|
|
|
|
Object.entries(deps).forEach(([packageName, packageData]) => {
|
|
|
|
const packageScripts = packageData.scripts || {}
|
|
|
|
const scriptKeys = Reflect.ownKeys(packageScripts)
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const hasInstallScript = installScripts.some((installKey) => scriptKeys.includes(installKey))
|
2019-11-20 01:03:20 +01:00
|
|
|
if (!hasInstallScript) {
|
|
|
|
return
|
|
|
|
}
|
2019-09-25 14:01:10 +02:00
|
|
|
|
|
|
|
const matchingScripts = {}
|
2019-11-20 01:03:20 +01:00
|
|
|
if (packageScripts.preinstall) {
|
|
|
|
matchingScripts.preinstall = packageScripts.preinstall
|
|
|
|
}
|
|
|
|
if (packageScripts.install) {
|
|
|
|
matchingScripts.install = packageScripts.install
|
|
|
|
}
|
|
|
|
if (packageScripts.postinstall) {
|
|
|
|
matchingScripts.postinstall = packageScripts.postinstall
|
|
|
|
}
|
2019-09-25 14:01:10 +02:00
|
|
|
const scriptNames = Reflect.ownKeys(matchingScripts)
|
|
|
|
|
|
|
|
const relativePath = path.relative(process.cwd(), packageData.path)
|
|
|
|
|
|
|
|
console.log(`${packageName}: ${relativePath} ${scriptNames}`)
|
|
|
|
})
|
|
|
|
})
|