This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
78 lines (69 loc) · 2.04 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
// Require all the things (that we need).
const gulp = require('gulp');
const notify = require('gulp-notify');
const rename = require('gulp-rename');
const shell = require('gulp-shell');
const sort = require('gulp-sort');
const uglify = require('gulp-uglify');
const watch = require('gulp-watch');
const wp_pot = require('gulp-wp-pot');
// Define the source paths for each file type.
const src = {
js: ['assets/js/wpcampus.js', 'assets/js/wpcampus-data.js'],
php: ['**/*.php','!vendor/**','!node_modules/**']
};
const dest = {
js: 'assets/js',
translations: 'languages/wpcampus-wp-theme.pot'
};
// Minify the JS.
gulp.task('js', function() {
gulp.src(src.js)
.pipe(uglify({
mangle: false
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(dest.js))
.pipe(notify('WPC Main JS compiled'));
});
// "Sniff" our PHP.
gulp.task('php', function() {
// TODO: Clean up. Want to run command and show notify for sniff errors.
return gulp.src('index.php', {read: false})
.pipe(shell(['composer sniff'], {
ignoreErrors: true,
verbose: false
}))
.pipe(notify('WPC Main PHP sniffed'), {
onLast: true,
emitError: true
});
});
// Create the .pot translation file.
gulp.task('translate', function () {
gulp.src('**/*.php')
.pipe(sort())
.pipe(wp_pot( {
domain: 'wpcampus',
package: 'wpcampus-wp-theme',
bugReport: 'https://github.com/wpcampus/wpcampus-wp-theme/issues',
lastTranslator: 'WPCampus <[email protected]>',
team: 'WPCampus <[email protected]>',
headers: false
} ))
.pipe(gulp.dest(dest.translations))
.pipe(notify('WPC Main translated'));
});
// Compile all the things.
gulp.task('compile',['js']);
// Test all the things.
gulp.task('test',['php']);
// I've got my eyes on you(r file changes).
gulp.task('watch', function() {
gulp.watch(src.js, ['js']);
gulp.watch(src.php, ['translate','php']);
});
// Let's get this party started.
gulp.task('default', ['compile','translate','test']);