Quickhand Version of loading Grunt NpmTasks

Going the long way! Why don’t you use this to load your grunt NpmTasks?

require(‘matchdep’).filterDev(‘grunt-*).forEach(grunt.loadNpmTasks);

instead of

grunt.loadNpmTasks(‘grunt-karma’);
grunt.loadNpmTasks(‘grunt-contrib-uglify’);
grunt.loadNpmTasks(‘grunt-contrib-watch’);
grunt.loadNpmTasks(‘grunt-nodemon’);
grunt.loadNpmTasks(‘grunt-concurrent’);
grunt.loadNpmTasks(‘grunt-docular’);
grunt.loadNpmTasks(‘grunt-ngmin’);
grunt.loadNpmTasks(‘grunt-jasmine-node’);

This will search the package.json file and automatically add those tasks to your grunt config. Very nice.

How it works

It uses npm matchdep to filter npm module dependencies by name then we search on .filterDev which will search the devDependencies in our package.json the for each one found run the grunt.loadNpmTasks function with the package name as the parameter.