forked from Runalyze/Runalyze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (77 loc) · 2.73 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
'use strict';
var del = require('del');
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
var less = require('gulp-less');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var shell = require('gulp-shell');
var phpunit = require('gulp-phpunit');
var config = require('./resources.json');
function clean(done) {
return del([
config.less.dest + "*.css",
config.js.dest + "*.js"
], done);
}
clean.description = 'Clean output files.';
function styles() {
return gulp.src(config.less.main.src)
.pipe(sourcemaps.init())
.pipe(less({ relativeUrls: true, paths: [ config.less.main.root ] }))
.pipe(cleanCSS({ rebase: true, rebaseTo: config.less.dest }))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.less.dest));
}
styles.description = 'Run less to generate stylesheets.';
function stylesInstaller() {
return gulp.src(config.less.installer.src)
.pipe(sourcemaps.init())
.pipe(less({ relativeUrls: true, paths: [ config.less.installer.root ] }))
.pipe(cleanCSS({ rebase: true, rebaseTo: config.less.dest }))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.less.dest));
}
stylesInstaller.description = 'Run less to generate stylesheets for the installer.';
function scripts() {
return gulp.src(config.js.src)
.pipe(sourcemaps.init())
.pipe(concat('scripts.min.js'))
.pipe(gulp.dest(config.js.dest))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.js.dest));
}
scripts.description = 'Combine and minify javascript files.';
function tests() {
return gulp.src('./tests/config.xml')
.pipe(phpunit('./vendor/bin/phpunit', { bootstrap: './tests/bootstrap.php', statusLine: false }));
}
tests.description = 'Run phpunit.';
function translate() {
return gulp.src('./vendor/runalyze/translations/gettext/*/*/*.po', {read: false})
.pipe(shell([
'cp <%= file.path %> ./vendor/runalyze/translations/gettext', // Needed for symfony
]))
.pipe(shell([
'msgfmt -v <%= file.path %> -o <%= target(file.path) %>'
], {
templateData: {
target: function (f) {
return f.replace(/messages\.(.*)\.po$/, 'runalyze.mo')
}
}
}))
}
translate.description = 'Compile translation files.';
exports.clean = clean;
exports.styles = styles;
exports.stylesInstaller = stylesInstaller;
exports.scripts = scripts;
exports.tests = tests;
exports.translate = translate;
var build = gulp.series(clean, gulp.parallel(styles, stylesInstaller, scripts));
gulp.task('build', build);
gulp.task('default', gulp.parallel(build, translate));