-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
36 lines (28 loc) · 925 Bytes
/
index.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
var gulp = require('gulp');
var elixir = require('laravel-elixir');
var KarmaServer = require('karma').Server;
var _ = require('underscore');
var gutils = require('gulp-util');
var task = elixir.Task;
function isTddOrWatchTask() {
return gutils.env._.indexOf('watch') > -1 || gutils.env._.indexOf('tdd') > -1;
}
elixir.extend('karma', function(args) {
if (! isTddOrWatchTask()) return;
var defaults = {
configFile: process.cwd() + '/karma.conf.js',
jsDir: ['resources/assets/js/**/*.js', 'resources/assets/coffee/**/*.coffee'],
autoWatch: true,
singleRun: false
};
var options = _.extend(defaults, args);
var server;
var isStarted = false;
new task('karma', function() {
if( ! isStarted) {
server = new KarmaServer(options);
server.start();
isStarted = true;
}
}).watch(options.jsDir, 'tdd');
});