-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
123 lines (104 loc) · 3.51 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Build automation
// Require sudo npm install -g gulp
// For dev, initiate watch by executing either `gulp` or `gulp watch`
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify-es').default,
shell = require('gulp-shell'),
rename = require('gulp-rename'),
exec = require('child_process').exec;
var babelify = require('babelify');
var path = {
mainJs: './src/main/js/main_html5.js',
flashOSMFJs: './src/osmf/js/osmf_flash.js',
flashAkamaiJs: './src/akamai/js/akamaiHD_flash.js',
youtubeJs: './src/youtube/js/youtube.js'
};
var main_html5_fn = function() {
uglify_fn(path.mainJs);
};
var osmf_fn = function() {
uglify_fn(path.flashOSMFJs);
};
var akamai_fn = function() {
uglify_fn(path.flashAkamaiJs);
};
var youtube_fn = function() {
uglify_fn(path.youtubeJs);
};
var uglify_fn = function(srcFile) {
var transform = [babelify];
//excluding OSMF from babelify since it has a lot of code
//that conflicts with strict mode
if (srcFile.indexOf(path.flashOSMFJs) >= 0) {
transform = [];
}
var b = browserify({
entries: srcFile,
debug: false,
transform: transform
});
b.bundle()
.pipe(source(getFileNameFromPath(srcFile)))
.pipe(buffer())
.pipe(gulp.dest('./build/'))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('./build/'));
};
var getFileNameFromPath = function(path) {
var start = path.lastIndexOf('/') + 1;
return path.substring(start);
};
// Dependency task
gulp.task('init_module', function(callback) {
exec("git submodule update --init && cd html5-common && npm install && cd ..", function(err) {
if (err) return callback(err);
callback();
});
});
gulp.task('build_flash_osmf', function(callback) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes wrapper", function(err) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes build-CC-osmf", function(err) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes build-osmf", function(err) {
if (err) console.log("Error occured in building osmf plugin : " + err);
else {osmf_fn();}
exec("ant -buildfile build_flash.xml -Dbuild=build/classes clean-osmf", function(err) {
if (err) return callback(err);
callback();
});
});
});
});
});
gulp.task('build_flash_akamai', function(callback) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes wrapper", function(err) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes build-CC-akamai", function(err) {
exec("ant -buildfile build_flash.xml -Dbuild=build/classes build-akamai", function(err) {
if (err) console.log("Error occured in building akamai plugin : " + err);
else {akamai_fn();}
exec("ant -buildfile build_flash.xml -Dbuild=build/classes clean-akamai", function(err) {
if (err) return callback(err);
callback();
});
});
});
});
});
gulp.task('build', ['init_module', 'build_flash_osmf', 'build_flash_akamai'], function() {
youtube_fn();
main_html5_fn();
});
gulp.task('test', shell.task(['jest --verbose']));
// Initiate a watch
gulp.task('watch', function() {
gulp.watch("src/**/*", ['build']);
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['build']);
// Generate documentation
gulp.task("docs", shell.task("./node_modules/.bin/jsdoc -c ./jsdoc_conf.json"));