-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
52 lines (45 loc) · 1.22 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var grunt = require('grunt'),
_ = require('underscore'),
nodePath = require('path'),
fs = require('fs');
var config = {};
// grunt
module.exports = function(grunt) {
config = _.extend(config, {
pkg: grunt.file.readJSON('package.json'),
dirname: __dirname,
mochaTest: {
options: {
clearRequireCache: true,
mocha: require('mocha'),
reporter: 'spec'
},
test: {
src: [ 'test/*.js' ]
}
},
watch: {
test: {
options: {
spawn: false,
interrupt: true
},
files: [ '**/*.js', '!**/node_modules/**' ],
tasks: [ 'mochaTest:test' ]
}
}
});
grunt.initConfig(config);
// On watch events configure mochaTest to run only on the test if it is one
// otherwise, run the whole testsuite
var defaultSimpleSrc = grunt.config('mochaTest.simple.src');
grunt.event.on('watch', function(action, filepath) {
grunt.config('mochaTest.simple.src', defaultSimpleSrc);
if (filepath.match('test/')) {
grunt.config('mochaTest.simple.src', filepath);
}
});
// Load grunt tasks from NPM packages
require( 'load-grunt-tasks' )( grunt );
grunt.registerTask('default', [ 'watch' ] );
};