-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
71 lines (60 loc) · 1.4 KB
/
gulpfile.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
'use strict';
// Gulp configuration:
var config = require('./gulp.config')();
// Imports:
var gulp = require('gulp');
var util = require('gulp-util');
var karma = require('karma').server;
var _ = require('lodash');
// Tasks:
gulp.task('tdd', tddTask);
gulp.task('karma', karmaTask);
gulp.task('coverage', coverageTask);
/**
* Test driven development task.
*/
function coverageTask(done) {
log('Starting a continuous "watch and test" cycle');
startKarma('coverage', done);
}
/**
* Test driven development task.
*/
function tddTask(done) {
log('Starting a continuous "watch and test" cycle');
startKarma('tdd', done);
}
/**
* Runs karma with default configuration.
*/
function karmaTask(done) {
startKarma('x', done);
}
/**
* Runs karma with given configuration type
*
* @param {string} configType
* @param callback
*/
function startKarma(configType, callback) {
var options = _.merge(
config.karma.default,
config.karma[configType] || {}
);
karma.start(options, callback);
}
/**
* Log a message or series of messages using chalk's blue color.
* Can pass in a string, object or array.
*/
function log(msg) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
util.log($.util.colors.blue(msg[item]));
}
}
} else {
util.log(util.colors.blue(msg));
}
}