-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
78 lines (71 loc) · 1.83 KB
/
gulpfile.js
File metadata and controls
78 lines (71 loc) · 1.83 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
let gulp = require('gulp');
let notify = require('gulp-notify');
let eslint = require('gulp-eslint');
let phpcs = require('gulp-phpcs');
let phpunit = require('gulp-phpunit');
let _ = require('lodash');
/** ************
* PHP *
**************/
gulp.task('php_cs', function() {
return gulp.src([
'src/**/*.php',
'config/*.php',
'tests/*.php',
'tests/**/*.php',
'config/**/*.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'));
});
/**
* Returns the configuration for a gulp-notify notification
*
* @param {string} status
* @param {string} pluginName
* @param {Object} override
* @return {{title: string, message: string, icon: string}}
*/
function testNotification(status, pluginName, override) {
let 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', {})));
});
/** ************
* Javascript *
**************/
let srcJsFiles = [
'webroot/js/*.js',
];
gulp.task('js_lint', () => {
return gulp.src(srcJsFiles)
.pipe(eslint({
globals: [
'jQuery',
'$',
],
}))
.pipe(eslint.format());
});