This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGruntfile.js
151 lines (131 loc) · 4.24 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
// jscs:disable
var exec = require('child_process').exec;
module.exports = function (grunt) {
//npm install
grunt.registerTask('npm_install', 'install dependencies', function() {
var cb = this.async();
exec('npm install', {cwd: './'}, function(err, stdout) {
console.log(stdout);
cb();
});
});
grunt.registerTask('open_coverage', 'open coverage report in default browser', function() {
var cb = this.async();
exec('open coverage/lcov-report/index.html', {cwd: './'}, function(err, stdout) {
console.log(stdout);
cb();
});
});
grunt.registerTask('open_docs', 'open documentation in default browser', function() {
var cb = this.async();
exec('open docs/index.html', {cwd: './'}, function(err, stdout) {
console.log(stdout);
cb();
});
});
grunt.initConfig({
//clean node_modules directory except for grunt
clean: {
options:{
// force: true
},
node_modules:['node_modules/*','!node_modules/grunt*'],
coverage:['coverage/*'],
docs: ['docs/*']
},
env: {
options: {
},
test: {
NODE_ENV: 'test',
XUNIT_FILE: 'coverage/TESTS-all.xml'
}
},
mochaTest: {
test: {
options: {
reporter: 'spec-xunit-file',
timeout: 15000
},
src: ['test/**/*.js']
}
},
mocha_istanbul: {
coverage: {
src: 'test', // the folder name for the tests
options: {
recursive: true,
coverage: true, // emit the coverage event
//quiet: true,
excludes: [],
mochaOptions: [
'--reporter', 'spec-xunit-file'
]
}
}
},
jshint: {
files: [
'engine.js',
'lib/*.js'
],
options: {
jshintrc: '.jshintrc'
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jscs: {
options: {
config: '.jscsrc',
reporter: require('jscs-stylish').path
},
all: {
src: [
'engine.js',
'lib/{,*/}*.js',
'test/{,*/}*Spec.js'
]
},
test: {
src: [
'test/{,*/}*Spec.js'
]
}
},
jsdoc : {
dist : {
src: ['engine.js', 'lib/*.js', 'timing/*.js', 'README.md'],
options: {
destination: 'docs',
template : 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
configure: '.jsdoc.conf.json'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-develop');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-jsdoc');
// handle coverage event by sending data to coveralls
grunt.event.on('coverage', function(lcov, done){
require('coveralls').handleInput(lcov, function(err){
if (err) {
return done(err);
}
done();
});
});
// Register group tasks
grunt.registerTask('clean_all', [ 'clean:node_modules', 'clean:coverage', 'npm_install' ]);
grunt.registerTask('test', ['env:test', 'clean:coverage', 'jscs:all', 'jshint', 'mocha_istanbul']);
grunt.registerTask('coverage', ['test', 'open_coverage' ]);
grunt.registerTask('generate-docs', ['clean:docs', 'jsdoc']);
grunt.registerTask('view-docs', ['generate-docs', 'open_docs']);
};