-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (50 loc) · 1.88 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
const gulp = require('gulp'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
pkg = require('./_build/config.json');
const year = new Date().getFullYear();
let phpversion;
let modxversion;
pkg.dependencies.forEach(function (dependency, index) {
switch (pkg.dependencies[index].name) {
case 'php':
phpversion = pkg.dependencies[index].version.replace(/>=/, '');
break;
case 'modx':
modxversion = pkg.dependencies[index].version.replace(/>=/, '');
break;
}
});
const bumpCopyright = function () {
return gulp.src([
'core/components/minifyregistered/model/minifyregistered/minifyregistered.class.php',
'core/components/minifyregistered/src/MinifyRegistered.php',
], {base: './'})
.pipe(replace(/Copyright 2011(-\d{4})? by/g, 'Copyright ' (year > 2011 ? '2011-' : '') year ' by'))
.pipe(gulp.dest('.'));
};
const bumpVersion = function () {
return gulp.src([
'core/components/minifyregistered/src/MinifyRegistered.php',
], {base: './'})
.pipe(replace(/version = '\d \.\d \.\d [-a-z0-9]*'/ig, 'version = \'' pkg.version '\''))
.pipe(gulp.dest('.'));
};
const bumpDocs = function () {
return gulp.src([
'mkdocs.yml',
], {base: './'})
.pipe(replace(/© 2011(-\d{4})?/g, '© ' (year > 2011 ? '2011-' : '') year))
.pipe(gulp.dest('.'));
};
const bumpRequirements = function () {
return gulp.src([
'docs/index.md',
], {base: './'})
.pipe(replace(/[*-] MODX Revolution \d.\d.*/g, '* MODX Revolution ' modxversion ' '))
.pipe(replace(/[*-] PHP (v)?\d.\d.*/g, '* PHP ' phpversion ' '))
.pipe(gulp.dest('.'));
};
gulp.task('bump', gulp.series(bumpCopyright, bumpVersion, bumpDocs, bumpRequirements));
// Default Task
gulp.task('default', gulp.series('bump'));