A Grunt task to watch and run tasks on multiple Grunt projects
A Grunt Hub is just a folder with a Gruntfile and this grunt plugin installed. To create one do:
mkdir grunt-hub && cd grunt-hub
npm install grunt-hub
cp -R node_modules/grunt-hub/tasks/init/hub/* .
Then edit the grunt.js file to point to your other Grunt projects and run:
grunt
or grunt watch
.
Install this grunt plugin next to your project's
Gruntfile with: npm install grunt-hub
Then add this line to your project's Gruntfile:
grunt.loadNpmTasks('grunt-hub');
This plugin includes a hub
task and overrides the watch
task.
hub
taskThe hub task is for running tasks on multiple projects. It would like to know
which Gruntfiles to use and which tasks to run on each Grunt project. For example
if I would like to lint
and test
on every Grunt project one folder up:
grunt.initConfig({
hub: {
all: {
files: ['../*/grunt.js'],
tasks: ['lint', 'test']
}
}
});
watch
taskThe watch task is for watching multiple Grunt projects and triggering tasks on
the respective Grunt project as files are edited. This watch task will read each
project's Gruntfile and use each watch
config to determine which files to watch
and which tasks to run.
To specify which Gruntfiles this watch task should read use:
grunt.initConfig({
watch: '../*/grunt.js',
});
or if you're using the above hub
config, simply:
grunt.initConfig({
watch: '<config:hub.all.files>',
});
Please open an issue or send a pull request. Thanks!
Copyright (c) 2012 Kyle Robinson Young
Licensed under the MIT license.