-
Notifications
You must be signed in to change notification settings - Fork 56
/
grunt.js
56 lines (47 loc) · 1.67 KB
/
grunt.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
module.exports = function (grunt) {
grunt.loadTasks('build');
grunt.initConfig({
html2js: {
src: ['1820EN_*/**/template/**/*.html']
},
lint: {
files:['grunt.js', '1820EN_*/**/*.js']
}
});
// Default task
grunt.registerTask('default', 'lint html2js test');
grunt.registerTask('travis', 'lint html2js test-travis');
// Karma configuration
function runKarma(command, options) {
var karmaCmd = process.platform === 'win32' ? 'karma.cmd' : 'karma';
var args = [command].concat(options);
var done = grunt.task.current.async();
var child = grunt.utils.spawn({
cmd: karmaCmd,
args: args
}, function(err, result, code) {
if (code) {
done(false);
} else {
done();
}
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
}
grunt.registerTask('test', 'run tests on single-run server', function() {
runKarma('start', ['--single-run', '--no-auto-watch', '--log-level=warn']);
});
grunt.registerTask('server', 'start karma server', function() {
runKarma('start', ['--no-single-run', '--no-auto-watch']);
});
grunt.registerTask('test-run', 'run tests against continuous karma server', function() {
runKarma('run', ['--single-run', '--no-auto-watch']);
});
grunt.registerTask('test-watch', 'start karma server, watch & execute tests', function() {
runKarma('start', ['--no-single-run', '--auto-watch']);
});
grunt.registerTask('test-travis', 'run tests on travis', function() {
runKarma('start', ['--single-run', '--no-auto-watch', '--log-level=warn', '--browsers=Firefox']);
});
};