-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (59 loc) · 1.66 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
var gulp = require("gulp");
var uglify = require("gulp-uglify");
var concat = require("gulp-concat");
var replace = require('gulp-replace-task');
var fs = require('fs');
var rename = require("gulp-rename");
var runSequence = require("run-sequence");
var del = require("del");
gulp.task("uglify", function() {
return gulp.src(['www/*.js', '!www/NavigatorPresentation.js'])
.pipe(concat('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('www/dist'));
});
gulp.task("receiver_min", function() {
return gulp.src(['src/android/receiver.js'])
.pipe(concat('receiver_min.js'))
.pipe(uglify())
.pipe(replace({
patterns: [
{
match: /"/g,
replacement: function() {
return "'";
}
}
]
}))
.pipe(gulp.dest('src/android'));
});
var fileContent;
gulp.task("receiver_load", function(callback) {
fs.readFile('src/android/receiver_min.js', 'utf8', function(err, file) {
fileContent = file;
callback();
})
});
gulp.task('receiver_insert', function () {
return gulp.src('src/android/NavigatorPresentationJS_unprepared.java')
.pipe(replace({
patterns: [
{
match: 'RECEIVER_MIN',
replacement: fileContent
}
]
}))
.pipe(rename("NavigatorPresentationJS.java"))
.pipe(gulp.dest('src/android/'));
});
gulp.task('receiver_cleanup', function() {
return del(['src/android/receiver_min.js']);
});
gulp.task("default", function(callback) {
runSequence("uglify", "receiver", callback);
});
gulp.task("receiver", function(callback) {
runSequence("receiver_min", "receiver_load", "receiver_insert", "receiver_cleanup", callback);
});