-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
53 lines (49 loc) · 1.84 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
const gulp = require('gulp'),
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;
}
});
gulp.task('bump-copyright', function () {
return gulp.src([
'core/components/formit2db/model/formit2db/formit2db.class.php',
'core/components/formit2db/src/FormIt2Db.php',
], {base: './'})
.pipe(replace(/Copyright 2013(-\d{4})? by/g, 'Copyright ' + (year > 2013 ? '2013-' : '') + year + ' by'))
.pipe(gulp.dest('.'));
});
gulp.task('bump-version', function () {
return gulp.src([
'core/components/formit2db/src/FormIt2db.php',
], {base: './'})
.pipe(replace(/version = '\d+.\d+.\d+[-a-z0-9]*'/ig, 'version = \'' + pkg.version + '\''))
.pipe(gulp.dest('.'));
});
gulp.task('bump-docs', function () {
return gulp.src([
'mkdocs.yml',
], {base: './'})
.pipe(replace(/© 2013(-\d{4})?/g, '© ' + (year > 2013 ? '2013-' : '') + year))
.pipe(gulp.dest('.'));
});
gulp.task('bump-requirements', 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('bump-copyright', 'bump-version', 'bump-docs', 'bump-requirements'));
// Default Task
gulp.task('default', gulp.series('bump'));