-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
41 lines (36 loc) · 1.37 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
module.exports = function(grunt) {
grunt.initConfig({
watch: {
dev: {
expand: true,
files: [ "src/**/*.js", "test/**/*.js" ],
tasks: [ 'jshint', 'mochaTest' ],
options: {
spawn: false
}
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: true, // https://github.com/pghalliday/grunt-mocha-test#running-in-permanent-environments-like-watch
require: [ "hook" ],
colors: false
},
src: ['test/**/*.spec.js']
}
}
});
// on watch events configure babel to only run on changed file
grunt.event.on('watch', function(action, filepath) {
testpath = /\.spec\.js$/.test(filepath) ? filepath : filepath.replace(/^src/, 'test').replace(/\.js$/, '.spec.js');
grunt.config('mochaTest.test.src', testpath);
grunt.config('jshint.src', filepath);
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['watch']);
};