Running tasks configured across multiple grunt.js files

I have a node app that includes multiple unpublished modules. My app's package.json includes a few git dependencies:

"module-a": "git+ssh://git@github.com:me/module-a.git",
"module-b": "git+ssh://git@github.com:me/module-b.git"    

and each of those have their own grunt config. Eg in node_modules/module-a/grunt.js:

module.exports = function(grunt) {

grunt.initConfig({
    lint: {
        files: ['server/**/*.js', 'test/**/*.js']
    },
    jshint: {
        options: require('./lint-ci')
    }
});

grunt.registerTask('default', 'lint');

};

(they also run tests, etc, but I'm keeping it simple here)

Is there a built-in way to do this with grunt? Note that I want to keep the dependent grunt.js files for convenience when I've only changed something within that dependency.

The only solutions I have found are

  • build up my main grunt.js programmatically (eg, iterating over my dependencies in package.json to build the lint and test config)
  • call grunt multiple times using --config node_modules/module-a/grunt.js

Neither seems ideal. Is there a better way?

Just a thought but have you looked at grunt-hub?

https://github.com/shama/grunt-hub