-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
71 lines (63 loc) · 1.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Many thanks to Shadi Abu Hilal for his demonstration repository:
* https://github.com/shadiabuhilal/js-code-coverage-example
* Testing client-side JavaScript is a lot more difficult than
* testing Node.js applications.
*/
'use strict';
var istanbul = require('browserify-istanbul');
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-mocha-phantom-istanbul');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
options: {
browserifyOptions: {
debug: true
},
postBundleCB: function(err, buffer, next) {
var code = grunt.template.process(buffer.toString(), {
data: grunt.file.readJSON('package.json')
});
next(err, code);
}
},
coverage: {
files: {
'build/cs.js': 'src/cs.js'
},
options: {
transform: [istanbul]
}
}
},
clean: {
tests: ['build', 'coverage']
},
mocha: {
options: {
run: true,
reporter: 'Spec',
coverage: {
lcovReport: 'coverage'
}
},
test: {
src: ['test/**/*.html']
}
},
uglify: {
options: {
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
},
build: {
src: 'src/cs.js',
dest: 'src/cs.min.js'
}
}
});
grunt.registerTask('default', ['uglify', 'clean', 'browserify:coverage', 'mocha']);
};