-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (51 loc) · 1005 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
/**
* Require dependencies
*/
var gulp = require('gulp'),
cache = require('gulp-cached'),
beep = require('beepbeep'),
plumber = require('gulp-plumber'),
phpcs = require('gulp-phpcs');
/**
* Setup files to watch
*
* Concat contains extra files to concat
*/
var files = [
'**/*.php',
'!node_modules/**/*.*'
];
/**
* Error handling
*/
var gulp_src = gulp.src;
gulp.src = function() {
return gulp_src.apply(gulp, arguments)
.pipe(plumber(function(error) {
beep();
}));
};
/**
* PHP CodeSniffer (PSR)
*/
gulp.task('phpcs', function() {
return gulp.src(files)
// Use cache to filter out unmodified files
.pipe(cache('phpcs'))
// Sniff code
.pipe(phpcs({
bin: '~/.composer/vendor/bin/phpcs',
standard: 'PSR2',
warningSeverity: 0
}))
// Log errors and fail afterwards
.pipe(phpcs.reporter('log'))
.pipe(phpcs.reporter('fail'));
});
/**
* Watch
*/
gulp.task('default', function() {
gulp.watch(files, ['phpcs']);
});