1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | module.exports = function(grunt) {
|
13 |
|
14 |
|
15 | grunt.initConfig({
|
16 | nodeunit: {
|
17 | all: ['test/{grunt,tasks,util}/**/*.js']
|
18 | },
|
19 | jshint: {
|
20 | gruntfile: ['Gruntfile.js'],
|
21 | libs_n_tests: ['lib/**/*.js', '<%= nodeunit.all %>'],
|
22 | subgrunt: ['<%= subgrunt.all %>'],
|
23 | options: {
|
24 | curly: true,
|
25 | eqeqeq: true,
|
26 | immed: true,
|
27 | latedef: true,
|
28 | newcap: true,
|
29 | noarg: true,
|
30 | sub: true,
|
31 | undef: true,
|
32 | unused: true,
|
33 | boss: true,
|
34 | eqnull: true,
|
35 | node: true,
|
36 | es5: true
|
37 | }
|
38 | },
|
39 | watch: {
|
40 | gruntfile: {
|
41 | files: ['<%= jshint.gruntfile %>'],
|
42 | tasks: ['jshint:gruntfile']
|
43 | },
|
44 | libs_n_tests: {
|
45 | files: ['<%= jshint.libs_n_tests %>'],
|
46 | tasks: ['jshint:libs_n_tests', 'nodeunit']
|
47 | },
|
48 | subgrunt: {
|
49 | files: ['<%= subgrunt.all %>'],
|
50 | tasks: ['jshint:subgrunt', 'subgrunt']
|
51 | }
|
52 | },
|
53 | subgrunt: {
|
54 | all: ['test/gruntfile/*.js']
|
55 | },
|
56 | });
|
57 |
|
58 |
|
59 | grunt.loadNpmTasks('grunt-contrib-jshint');
|
60 | grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
61 | grunt.loadNpmTasks('grunt-contrib-watch');
|
62 |
|
63 |
|
64 | grunt.registerTask('test', ['jshint', 'nodeunit', 'subgrunt']);
|
65 |
|
66 |
|
67 | grunt.registerTask('default', ['test']);
|
68 |
|
69 |
|
70 | grunt.registerMultiTask('subgrunt', 'Run a sub-gruntfile.', function() {
|
71 | var path = require('path');
|
72 | grunt.util.async.forEachSeries(this.filesSrc, function(gruntfile, next) {
|
73 | grunt.util.spawn({
|
74 | grunt: true,
|
75 | args: ['--gruntfile', path.resolve(gruntfile)],
|
76 | }, function(error, result) {
|
77 | if (error) {
|
78 | grunt.log.error(result.stdout).writeln();
|
79 | next(new Error('Error running sub-gruntfile "' + gruntfile + '".'));
|
80 | } else {
|
81 | grunt.verbose.ok(result.stdout);
|
82 | next();
|
83 | }
|
84 | });
|
85 | }, this.async());
|
86 | });
|
87 |
|
88 | };
|