forked from hirak/prestissimo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (59 loc) · 1.49 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
/**
* gulpfile.js for php-library developement
*
* 1. install node.js & npm
* 2. $ npm install
* 3. $ npm start
*/
var gulp = require('gulp');
var exec = require('child_process').exec;
var bs = require('browser-sync').create();
gulp.task('default', ['test', 'inspect']);
function test(done) {
var p = exec('composer fasttest');
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', done);
}
function inspect(done) {
var r = 3;
function wait() {
--r || done();
}
exec('composer doc', wait);
exec('composer metrics', wait);
var lint = exec('composer lint');
lint.stdout.pipe(process.stdout);
lint.stderr.pipe(process.stderr);
lint.on('exit', wait);
}
function lint(target, done) {
var p = exec('composer lint -- ' + target);
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', done);
}
gulp.task('test', test);
gulp.task('inspect', inspect);
gulp.task('start', function(){
bs.init({
server: {
baseDir: "artifacts/"
},
ghostMode: false
});
gulp.watch(['src/**/*.php', 'tests/**/*Test.php'], {}, function(ev){
switch (ev.type) {
case "added":
case "changed":
lint(ev.path, function(){
test(bs.reload);
});
break;
default:
inspect(function(){
test(bs.reload);
});
}
});
});