-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
104 lines (84 loc) · 2.75 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var gulp = require('gulp');
var less = require('gulp-less');
var notify = require("gulp-notify");
var LessPluginCleanCSS = require('less-plugin-clean-css');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var phpcs = require('gulp-phpcs');
var phpunit = require('gulp-phpunit');
var _ = require('lodash');
function customNotify(message) {
return notify({
title: 'Muncie Events API',
message: function(file) {
return message + ': ' + file.relative;
}
})
}
phpCS = function (cb) {
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'));
};
gulp.task('default', phpCS);
/**************
* PHP *
**************/
gulp.task('php_cs', phpCS);
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')));
});
/**************
* Javascript *
**************/
var srcJsFiles = [
'webroot/js/script.js'
];
gulp.task('js_lint', function () {
return gulp.src(srcJsFiles)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(customNotify('JS linted'));
});
/**************
* LESS *
**************/
var srcLessFiles = [
'webroot/css/style.less'
];
gulp.task('less', function () {
var cleanCSSPlugin = new LessPluginCleanCSS({advanced: true});
gulp.src(srcLessFiles)
.pipe(less({plugins: [cleanCSSPlugin]}))
.pipe(gulp.dest('webroot/css'))
.pipe(customNotify('LESS compiled'));
});
/********************
* NPM DEPENDENCIES *
********************/
gulp.task('copy_npm_dep', function () {
gulp.src('./node_modules/flatpickr/dist/flatpickr.min.css')
.pipe(gulp.dest('./webroot/flatpickr/'));
gulp.src('./node_modules/flatpickr/dist/flatpickr.min.js')
.pipe(gulp.dest('./webroot/flatpickr/'))
.pipe(customNotify('Files copied'));
});