grunt-hub
Advanced tools
Weekly downloads
Readme
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 Gruntfile file to point to your other Grunt projects and run:
grunt hub
.
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');
The common use for grunt-hub is for a development server. Where you would like to watch multiple projects and compile the SASS or concat/minify JS upon every project as you edit.
Depending on your system, there are various ways to ensure the grunt-hub stays alive. Such as with upstart and monit.
A simple way is to use nohup
and create a start.sh
script:
#!/bin/sh
DIR=`dirname $0`
/usr/bin/nohup /usr/local/bin/grunt --base $DIR hub --no-color &
echo "Grunt Hub Started"
and a stop.sh
script:
#!/bin/sh
ps -ef | sed -n '/grunt/{/grep/!p;}' | awk '{print$2}' | xargs -I kill {}
echo "Grunt Hub Stopped"
Put these in your grunt-hub folder and run ./start.sh
to start and
./stop.sh
to stop.
forever
is a another great way to watch multiple grunt projects forever.
npm install forever grunt grunt-cli grunt-hub --save-dev
package.json
:{
"name": "my-grunt-hub",
"version": "0.1.0",
"scripts": {
"start": "forever ./node_modules/.bin/grunt hub"
}
}
npm start
.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: {
src: ['../*/Gruntfile.js'],
tasks: ['jshint', 'nodeunit'],
},
},
});
If tasks
were omitted, it will run the default
tasks.
You can override tasks on the cli with args: grunt hub:all:watch
will run the watch
task on all projects instead of jshint, nodeunit
.
concurrent
Default: 3
Set to the number of concurrent task runs to spawn.
allowSelf
Default: false
By default, hub will skip its own Gruntfile. Set to true
to allow hub to
include itself.
Note: Only set this for tasks which are not part of the default
task of their respective Gruntfile, or an infinite loop will occur.
hub: {
all: {
options: {
allowSelf: true
},
src: ['./Gruntfile.js', '../client1/Gruntfile.js', '../client2/Gruntfile.js'],
},
},
watch
task go?It isn't necessary. Just npm install grunt-contrib-watch --save-dev
into your project folders. Then either add the watch
task to your tasks list in your hub task config. Or run with grunt hub:target:watch
.
Please open an issue or send a pull request. Thanks!
grunt-lib-contrib
. Include options in verbose output. Better spawn grunt in hub task.interrupt
option. Allow tasks
to be undefined. Update to run on Grunt v0.4.Copyright (c) 2018 Kyle Robinson Young
Licensed under the MIT license.
FAQs
A Grunt task to watch and run tasks on multiple Grunt projects
The npm package grunt-hub receives a total of 600 weekly downloads. As such, grunt-hub popularity was classified as not popular.
We found that grunt-hub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.