-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
73 lines (57 loc) · 1.78 KB
/
gulpfile.babel.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
'use strict';
const gulp = require('gulp');
const fs = require('fs');
const rimraf = require('rimraf');
const pipes = require('./gulp/pipes');
const config = require('./config.json');
const wpGizmoDirectory = process.cwd();
const productionDirectory = `${wpGizmoDirectory}/../${config.plugin.slug}/`;
const productionInc = productionDirectory + 'inc/';
function hello(done) {
console.log('Hi, I\'m Gizmo!');
console.log(`Plugin name is: ${config.plugin.name}`);
return done();
}
function lint(done) {
gulp.src('./gulpfile.babel.js')
.pipe(pipes.lint());
return done();
}
function watchGulpFile(done) {
gulp.watch('./gulpfile.babel.js', lint);
done();
}
function bundle(done) {
if (fs.existsSync(productionDirectory)) {
console.log('removing old production directory...');
rimraf.sync( productionDirectory );
}
fs.mkdirSync(productionDirectory);
fs.mkdirSync(`${productionDirectory}inc/`);
gulp.src(['*.php', '!wp-gizmo.php'])
.pipe(pipes.nameReplace())
.pipe(gulp.dest(productionDirectory));
gulp.src(['inc/*.php', '!inc/gizmo.php'])
.pipe(pipes.nameReplace())
.pipe(gulp.dest(productionInc));
gulp.src('wp-gizmo.php')
.pipe(pipes.nameReplace())
.pipe(pipes.renameSlug())
.pipe(gulp.dest(productionDirectory));
gulp.src('inc/gizmo.php')
.pipe(pipes.nameReplace())
.pipe(pipes.renameSlug())
.pipe(gulp.dest(productionInc));
gulp.src(config.filesToCopy)
.pipe(gulp.dest(productionDirectory));
gulp.src('inc/gizmo.php')
.pipe(pipes.nameReplace())
.pipe(pipes.renameSlug())
.pipe(gulp.dest(productionInc));
return done();
}
exports.hello = hello;
exports.lint = lint;
exports.watch = watchGulpFile;
exports.default = gulp.series(lint, watchGulpFile);
exports.bundle = bundle;