Skip to content

Instantly share code, notes, and snippets.

@wrumsby
Last active December 30, 2015 05:19
Show Gist options
  • Save wrumsby/7781474 to your computer and use it in GitHub Desktop.
Save wrumsby/7781474 to your computer and use it in GitHub Desktop.
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');
});
});
};
@wrumsby
Copy link
Author

wrumsby commented Dec 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment