This repository was 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
Expand file tree
/
Copy pathGruntfile.js
More file actions
130 lines (115 loc) · 3.81 KB
/
Gruntfile.js
File metadata and controls
130 lines (115 loc) · 3.81 KB
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
'use strict';
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: [
'index.js',
],
options: {
jshintrc: '.jshintrc'
}
},
jsonlint: {
specs: {
src: [ '2013/*.json', '2014/*.json' ]
}
},
jsdoc : {
dist : {
src: ['index.js', 'README.md'],
options: {
destination: 'docs',
template : 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
configure: '.jsdoc.conf.json'
}
}
}
});
// 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();
});
});
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-release');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-jsdoc');
// Register group tasks
grunt.registerTask('clean_all', [ 'clean:node_modules', 'clean:coverage', 'npm_install' ]);
grunt.registerTask('test', ['env:test', 'clean:coverage', 'jshint', 'jsonlint:specs', 'mocha_istanbul']);
grunt.registerTask('coverage', ['env:test', 'clean:coverage', 'jshint', 'mocha_istanbul', 'open_coverage' ]);
grunt.registerTask('generate-docs', ['clean:docs', 'jsdoc']);
grunt.registerTask('view-docs', ['generate-docs', 'open_docs']);
};