-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGruntfile.js
85 lines (75 loc) · 2.04 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
'use strict';
var path = require('path');
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.initConfig({
settings: {
},
clean: {
docs: ['./docs'],
node: ['./node_modules'],
coverage: {
src: ['./coverage']
}
},
env: {
options: {
},
test: {
NODE_ENV: 'test'
}
},
exec: {
flush: {
exitCode: 1,
cmd: function () {
var command = '(echo "flush_all"; sleep 1; echo "quit" ) | telnet localhost 11211';
grunt.log.writeln('> ' + command);
return command;
}
},
istanbul: {
cmd: function () {
var cover = 'istanbul cover --x "" node_modules/mocha/bin/_mocha -- --timeout 60000 --reporter spec tests/index.js';
var report = 'istanbul' + ' report ' + 'cobertura';
return cover + ' && ' + report;
}
},
mocha: {
cmd: function runMocha(xarg) {
var src = [];
var arg = xarg ? xarg.toLowerCase() : '';
if (arg === 'some-subtask'){
src = [ ];
} else {
src = [
'tests/*.js',
'!node_modules/**/*.js'
];
}
var files = grunt.file.expand(src);
var bin = path.resolve(__dirname, './node_modules/.bin/mocha');
var options = ' --colors --reporter spec --timeout 20000 ';
var cmd = bin + options + files.join(' ');
console.log(cmd);
return cmd;
}
}
},
jsdoc: {
dist: {
src: ['*.js', '!Gruntfile.js'],
options: {
destination: 'docs'
}
}
}
});
grunt.registerTask('coverage', ['exec:flush', 'clean:coverage', 'env:test', 'exec:istanbul']);
grunt.registerTask('docs', [ 'clean:docs', 'jsdoc' ]);
grunt.registerTask('test', 'Run Tests', function () {
grunt.task.run(['exec:flush', 'env:test', 'exec:mocha']);
});
grunt.registerTask('default', ['test']);
};