Completed
Push — master ( 36709f...e26ed7 )
by Hiraku
01:57
created

gulpfile.js (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
/**
2
 * gulpfile.js for php-library developement
3
 *
4
 * 1. install node.js & npm
5
 * 2. $ npm install
6
 * 3. $ gulp server
7
 * 4. open http://localhost:9001/ (livereload enabled)
8
 * 5. coding on src/*.php and tests/*.php
9
 *
10
 * enjoy!
11
 *
12
 * @license https://creativecommons.org/publicdomain/zero/1.0/ CC0-1.0 (No Rights Reserved.)
13
 * @link https://github.com/spindle/spindle-lib-template
14
 */
15
var gulp = require('gulp');
16
var exec = require('child_process').exec;
17
var connect = require('gulp-connect');
18
19
gulp.task('default', ['test', 'inspect']);
20
21
gulp.task('help', function(){
22
    console.log('gulp test\t... kick vendor/bin/phpunit command');
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
23
    console.log('gulp inspect\t... kick vendor/bin/apigen and vendor/bin/pdepend');
24
    console.log('gulp server\t... start static web server on http://localhost:9001/');
25
    console.log('\tcoverage report... http://localhost:9001/coverage/');
26
    console.log('\tApiGen document... http://localhost:9001/api/');
27
});
28
29
gulp.task('test', function(done){
30
    exec('vendor/bin/phpunit --colors=always', function(err, stdout, stderr){
31
        console.log(stdout);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
32
        console.error(stderr);
33
        done();
34
    });
35
});
36
37
gulp.task('inspect', function(done){
38
    var i = 0, count = function(){ if (++i > 1) done() };
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
39
    exec([
40
        'vendor/bin/pdepend',
41
        '--jdepend-chart=builds/pdepend.svg',
42
        '--overview-pyramid=builds/pyramid.svg',
43
        '--summary-xml=builds/summary.xml',
44
        'src/'].join(' '), count);
45
    exec('vendor/bin/apigen.php', count);
46
});
47
48
gulp.task('connect', ['default'], function(){
49
    connect.server({
50
        root: [__dirname + '/builds/'],
0 ignored issues
show
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
51
        port: 9001,
52
        livereload: true
53
    });
54
});
55
56
gulp.task('reload', ['test'], function(){
57
    return gulp.src('builds/coverage/**')
58
        .pipe(connect.reload());
59
});
60
61
gulp.task('server', ['connect'], function(){
62
    gulp.watch(['src/**', 'tests/**'], ['reload']);
63
});
64
65