You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.2 KiB

  1. /*
  2. * grunt
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2013 "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. // Project configuration.
  12. grunt.initConfig({
  13. nodeunit: {
  14. all: ['test/{grunt,tasks,util}/**/*.js']
  15. },
  16. jshint: {
  17. gruntfile: ['Gruntfile.js'],
  18. libs_n_tests: ['lib/**/*.js', '<%= nodeunit.all %>'],
  19. subgrunt: ['<%= subgrunt.all %>'],
  20. options: {
  21. curly: true,
  22. eqeqeq: true,
  23. immed: true,
  24. latedef: true,
  25. newcap: true,
  26. noarg: true,
  27. sub: true,
  28. undef: true,
  29. unused: true,
  30. boss: true,
  31. eqnull: true,
  32. node: true,
  33. es5: true
  34. }
  35. },
  36. watch: {
  37. gruntfile: {
  38. files: ['<%= jshint.gruntfile %>'],
  39. tasks: ['jshint:gruntfile']
  40. },
  41. libs_n_tests: {
  42. files: ['<%= jshint.libs_n_tests %>'],
  43. tasks: ['jshint:libs_n_tests', 'nodeunit']
  44. },
  45. subgrunt: {
  46. files: ['<%= subgrunt.all %>'],
  47. tasks: ['jshint:subgrunt', 'subgrunt']
  48. }
  49. },
  50. subgrunt: {
  51. all: ['test/gruntfile/*.js']
  52. },
  53. });
  54. // These plugins provide necessary tasks.
  55. grunt.loadNpmTasks('grunt-contrib-jshint');
  56. grunt.loadNpmTasks('grunt-contrib-nodeunit');
  57. grunt.loadNpmTasks('grunt-contrib-watch');
  58. // "npm test" runs these tasks
  59. grunt.registerTask('test', ['jshint', 'nodeunit', 'subgrunt']);
  60. // Default task.
  61. grunt.registerTask('default', ['test']);
  62. // Run sub-grunt files, because right now, testing tasks is a pain.
  63. grunt.registerMultiTask('subgrunt', 'Run a sub-gruntfile.', function() {
  64. var path = require('path');
  65. grunt.util.async.forEachSeries(this.filesSrc, function(gruntfile, next) {
  66. grunt.util.spawn({
  67. grunt: true,
  68. args: ['--gruntfile', path.resolve(gruntfile)],
  69. }, function(error, result) {
  70. if (error) {
  71. grunt.log.error(result.stdout).writeln();
  72. next(new Error('Error running sub-gruntfile "' + gruntfile + '".'));
  73. } else {
  74. grunt.verbose.ok(result.stdout);
  75. next();
  76. }
  77. });
  78. }, this.async());
  79. });
  80. };