-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (56 loc) · 1.84 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
/**
* gulpfile.js for php-library developement
*
* 1. install node.js & npm
* 2. $ npm install
* 3. $ gulp server
* 4. open http://localhost:9000/ (livereload enabled)
* 5. coding on src/*.php and tests/*.php
*
* enjoy!
*
* @license https://creativecommons.org/publicdomain/zero/1.0/ CC0-1.0 (No Rights Reserved.)
* @link https://github.com/spindle/spindle-lib-template
*/
var gulp = require('gulp');
var exec = require('child_process').exec;
var connect = require('gulp-connect');
gulp.task('default', ['test', 'inspect']);
gulp.task('help', function(){
console.log('gulp test\t... kick vendor/bin/phpunit command');
console.log('gulp inspect\t... kick vendor/bin/apigen and vendor/bin/pdepend');
console.log('gulp server\t... start static web server on http://localhost:9000/');
console.log('\tcoverage report... http://localhost:9000/coverage/');
console.log('\tApiGen document... http://localhost:9000/api/');
});
gulp.task('test', function(done){
exec('vendor/bin/phpunit', function(err, stdout, stderr){
console.log(stdout);
console.error(stderr);
done();
});
});
gulp.task('inspect', function(done){
var i = 0, count = function(){ if (++i > 1) done() };
exec([
'vendor/bin/pdepend',
'--jdepend-chart=builds/pdepend.svg',
'--overview-pyramid=builds/pyramid.svg',
'--summary-xml=builds/summary.xml',
'src/'].join(' '), count);
exec('vendor/bin/apigen.php', count);
});
gulp.task('connect', ['default'], function(){
connect.server({
root: [__dirname + '/builds/'],
port: 9000,
livereload: true
});
});
gulp.task('reload', ['test'], function(){
return gulp.src('builds/coverage/*')
.pipe(connect.reload());
});
gulp.task('server', ['connect'], function(){
gulp.watch(['src/*', 'tests/*'], ['reload']);
});