-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (31 loc) · 945 Bytes
/
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
var gulp = require("gulp"),
phpunit = require("gulp-phpunit"),
plumber = require('gulp-plumber'),
exec = require('child_process').exec;
var files = ['app/**/*.php', "tests/**/*.php"];
var isTest = function(file) {
return file.indexOf("tests/") === 0;
};
var runTest = function(file) {
var filename = (isTest(file))
? file
: "tests/"+file.replace(".php", "Test.php");
var options = {
testClass: filename,
stopOnFailure: true,
stopOnError: true
};
gulp.src(file)
.pipe(plumber({errorHandler: function () {}}))
.pipe(phpunit("./vendor/bin/phpunit", options));
};
var checkFile = function (file) {
var isTest = file.indexOf("Test.php");
(isTest >= 0) ? runTest(file) : runTest(file);
};
var monitor = function () {
gulp.watch(files)
.on('change', checkFile)
.on('add', checkFile);
};
exports.monitor = monitor;