subgrunt.js 976 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * grunt
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2014 "Cowboy" Ben Alman
  6. * Licensed under the MIT license.
  7. * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
  8. */
  9. 'use strict';
  10. module.exports = function(grunt) {
  11. // Run sub-grunt files, because right now, testing tasks is a pain.
  12. grunt.registerMultiTask('subgrunt', 'Run a sub-gruntfile.', function() {
  13. var path = require('path');
  14. grunt.util.async.forEachSeries(this.filesSrc, function(gruntfile, next) {
  15. grunt.log.write('Loading ' + gruntfile + '...');
  16. grunt.util.spawn({
  17. grunt: true,
  18. args: ['--gruntfile', path.resolve(gruntfile)],
  19. }, function(error, result) {
  20. if (error) {
  21. grunt.log.error().error(result.stdout).writeln();
  22. next(new Error('Error running sub-gruntfile "' + gruntfile + '".'));
  23. } else {
  24. grunt.log.ok().verbose.ok(result.stdout);
  25. next();
  26. }
  27. });
  28. }, this.async());
  29. });
  30. };