Created
July 10, 2015 08:38
-
-
Save tilap/145217666f1c464f1209 to your computer and use it in GitHub Desktop.
Find unused package in your nodeJS app with gulp task.
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
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