-
Notifications
You must be signed in to change notification settings - Fork 51
/
gulpfile.js
74 lines (57 loc) · 2.03 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
'use strict';
var path = require('path');
var gulp = require('gulp');
var bump = require('gulp-bump');
var replace = require('gulp-replace');
var handlebars = require('gulp-compile-handlebars');
var mkdir = require('mkdirp');
var pkg = path.join(__dirname, 'package.json');
var version = require(pkg).version;
var PROD = (process.env.NODE_ENV === 'production');
var sourceDirectory = path.join(__dirname, 'src');
var staticDirectory = path.join(__dirname, 'static');
var buildDirectory = path.join(__dirname, PROD ? 'dist' : 'build', 'red5pro-html-testbed-' + version);
var partialsDirectory = path.join(sourceDirectory, 'template', 'partial');
var defaultOptions = {
batch: [partialsDirectory]
}
var webappBuildDirectory = path.join(__dirname, 'dist-webapp');
mkdir.sync(buildDirectory);
gulp.task('compile', function (cb) {
gulp.src(path.join(sourceDirectory, 'page', '**', '*.html'))
.pipe(handlebars({
version: version
}, defaultOptions))
.pipe(gulp.dest(buildDirectory))
.on('end', cb);
});
gulp.task('move-scripts', gulp.series('compile', function (cb) {
gulp.src([path.join(sourceDirectory, 'page', '**', '*.js'),
path.join(sourceDirectory, 'page', '**', '*.css'),
path.join(sourceDirectory, 'page', '**', '*.swf')])
.pipe(gulp.dest(buildDirectory))
.on('end', cb);
}));
gulp.task('move-static', gulp.series('move-scripts', function (cb) {
gulp.src(path.join(staticDirectory, '**'))
.pipe(replace('$VERSION', version))
.pipe(gulp.dest(buildDirectory))
.on('end', cb);
}));
gulp.task('build', gulp.series('move-static', function (cb) {
cb();
}));
gulp.task('set-build-directory', function (cb) {
buildDirectory = webappBuildDirectory;
cb()
});
gulp.task('build:webapp', gulp.series(['set-build-directory', 'build']));
gulp.task('bump-version', function() {
var versionType = process.env.BUMP !== undefined ? process.env.BUMP : 'patch';
var files = [pkg];
gulp.src(files)
.pipe(bump({
type: versionType
}))
.pipe(gulp.dest(__dirname));
});