Skip to content

Instantly share code, notes, and snippets.

@tilap
Created July 10, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilap/145217666f1c464f1209 to your computer and use it in GitHub Desktop.
Save tilap/145217666f1c464f1209 to your computer and use it in GitHub Desktop.
Find unused package in your nodeJS app with gulp task.
var depcheck = require('depcheck');
var path = require('path');
gulp.task('unusedPackages', function() {
var options = {
withoutDev: false,
ignoreDirs: ['lib', 'locales', 'logs', 'public'],
ignoreMatches: ['gulp-*']
};
var root = path.resolve('.');
depcheck(root, options, function(unused) {
if(unused.dependencies.length > 0 || unused.devDependencies.length > 0) {
console.log('=> Some packages are useless and should be removed');
if(unused.dependencies.length > 0) {
console.log("- " + unused.dependencies.join("\n - "));
}
if(unused.devDependencies.length > 0) {
console.log("- (dev) " + unused.devDependencies.join("\n - "));
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment