Last active
February 10, 2017 16:03
-
-
Save mikerourke/cf743ed93bcba33a5cafada44cea5168 to your computer and use it in GitHub Desktop.
Check NPM Dependencies using depcheck
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 fs = require('fs'); | |
const depcheck = require('depcheck'); | |
const options = { | |
ignoreBinPackage: false, | |
ignoreDirs: [ | |
'client', | |
], | |
parsers: { // the target parsers | |
'*.js': depcheck.parser.es6, | |
'*.jsx': depcheck.parser.jsx, | |
}, | |
detectors: [ | |
depcheck.detector.requireCallExpression, | |
depcheck.detector.importDeclaration, | |
], | |
specials: [ | |
depcheck.special.eslint, | |
depcheck.special.webpack, | |
], | |
}; | |
depcheck(__dirname, options, (unused) => { | |
const unusedItems = | |
`{ | |
"dependencies": ${JSON.stringify(unused.dependencies)}, | |
"devDependencies": ${JSON.stringify(unused.devDependencies)}, | |
"missing": ${JSON.stringify(unused.missing)}, | |
"using": ${JSON.stringify(unused.using)}, | |
"invalidFiles": ${JSON.stringify(unused.invalidFiles)}, | |
"invalidDirs": ${JSON.stringify(unused.invalidDirs)} | |
}`; | |
fs.writeFileSync('dependencies.json', unusedItems); | |
console.log('Complete'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment