Last active
December 30, 2015 05:19
-
-
Save wrumsby/7781474 to your computer and use it in GitHub Desktop.
Installing NPM dependencies for child projects that use Grunt.
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
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'); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses grunt-install-dependencies.