-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
57 lines (48 loc) · 1.66 KB
/
gulpfile.js
File metadata and controls
57 lines (48 loc) · 1.66 KB
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
var gulp = require('gulp');
var notify = require("gulp-notify");
var phpcs = require('gulp-phpcs');
var phpunit = require('gulp-phpunit');
var _ = require('lodash');
var runSequence = require('run-sequence');
function customNotify(message) {
return notify({
title: 'CRI',
message: function(file) {
return message + ': ' + file.relative;
}
})
}
gulp.task('default', ['php']);
/**************
* PHP *
**************/
gulp.task('php', function(callback) {
return runSequence('php_cs', 'php_unit', callback);
});
gulp.task('php_cs', function (cb) {
return gulp.src(['src/**/*.php', 'config/*.php', 'tests/*.php', 'tests/**/*.php'])
// Validate files using PHP Code Sniffer
.pipe(phpcs({
bin: '.\\vendor\\bin\\phpcs.bat',
standard: '.\\vendor\\cakephp\\cakephp-codesniffer\\CakePHP',
errorSeverity: 1,
warningSeverity: 1
}))
// Log all problems that was found
.pipe(phpcs.reporter('log'));
});
function testNotification(status, pluginName, override) {
var options = {
title: ( status == 'pass' ) ? 'Tests Passed' : 'Tests Failed',
message: ( status == 'pass' ) ? 'All tests have passed!' : 'One or more tests failed',
icon: __dirname + '/node_modules/gulp-' + pluginName +'/assets/test-' + status + '.png'
};
options = _.merge(options, override);
return options;
}
gulp.task('php_unit', function() {
gulp.src('phpunit.xml')
.pipe(phpunit('', {notify: true}))
.on('error', notify.onError(testNotification('fail', 'phpunit')))
.pipe(notify(testNotification('pass', 'php_unit')));
});