Installing NPM dependencies for child projects that use Grunt.
module.exports = function(grunt) {
// ...
grunt.loadNpmTasks('grunt-install-dependencies');
grunt.registerTask('install-npm-dependencies', 'Installs NPM dependencies for child projects that use Grunt.', function () {
var projects = [];
grunt.file.expand('project/*').forEach(function (path) {
if (grunt.file.isDir(path)) {
grunt.file.recurse(path, function (abspath, rootdir, subdir, filename) {
if (filename === 'Gruntfile.js' && projects.indexOf(rootdir) === -1) {
projects.push(rootdir);
}
});
}
});
projects.forEach(function (project) {
grunt.config.set('task.install-dependencies.options.cwd', project);
grunt.task.run('install-dependencies');
});
});
};