-
Notifications
You must be signed in to change notification settings - Fork 170
/
gulpfile.js
75 lines (64 loc) · 1.57 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
72
73
74
75
/**
* gulpfile.js for php-library developement
*
* 1. install node.js & npm
* 2. $ npm install
* 3. $ npm start
*/
const { parallel, watch } = require('gulp');
const { exec } = require('child_process');
const bs = require('browser-sync').create();
exports.default = parallel(test, inspect)
function test(done) {
var p = exec('composer fasttest');
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', done);
};
exports.test = test;
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);
};
exports.inspect = inspect;
function lint(target, done) {
var p = exec('composer lint -- ' + target);
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
p.on('exit', done);
}
exports.start = function start(done) {
bs.init({
server: {
baseDir: "artifacts/"
},
ghostMode: false
});
const watcher = watch(['src/**/*.php', 'tests/**/*Test.php']);
watcher.on('change', function(path, stats) {
console.log(`File ${path} was changed`);
lint(path, function(){
test(bs.reload);
});
});
watcher.on('add', function(path, stats) {
console.log(`File ${path} was added`);
lint(path, function(){
test(bs.reload);
});
});
watcher.on('unlink', function(path, stats) {
console.log(`File ${path} was unlinked`);
inspect(function(){
test(bs.reload);
});
});
};