-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
104 lines (87 loc) · 3.18 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
var gulp = require('gulp');
var clean = require('gulp-clean');
var es = require('event-stream');
var rseq = require('gulp-run-sequence');
var zip = require('gulp-zip');
var shell = require('gulp-shell');
var chrome = require('./vendor/chrome/manifest');
var firefox = require('./vendor/firefox/package');
function pipe(src, transforms, dest) {
if (typeof transforms === 'string') {
dest = transforms;
transforms = null;
}
var stream = gulp.src(src);
transforms && transforms.forEach(function(transform) {
stream = stream.pipe(transform);
});
if (dest) {
stream = stream.pipe(gulp.dest(dest));
}
return stream;
}
gulp.task('clean', function() {
return pipe('./build', [clean()]);
});
gulp.task('chrome', function() {
return es.merge(
pipe('./libs/**/*', './build/chrome/libs'),
pipe('./img/**/*', './build/chrome/img'),
pipe('./js/**/*', './build/chrome/js'),
pipe('./css/**/*', './build/chrome/css'),
pipe('./vendor/chrome/browser.js', './build/chrome/js'),
pipe('./vendor/chrome/manifest.json', './build/chrome/')
);
});
gulp.task('firefox', function() {
return es.merge(
pipe('./libs/**/*', './build/firefox/data/libs'),
pipe('./img/**/*', './build/firefox/data/img'),
pipe('./js/**/*', './build/firefox/data/js'),
pipe('./css/**/*', './build/firefox/data/css'),
pipe('./vendor/firefox/browser.js', './build/firefox/data/js'),
pipe('./vendor/firefox/main.js', './build/firefox/data'),
pipe('./vendor/firefox/package.json', './build/firefox/')
);
});
gulp.task('safari', function() {
return es.merge(
pipe('./libs/**/*', './build/safari/likeastore.safariextension/libs'),
pipe('./img/**/*', './build/safari/likeastore.safariextension/img'),
pipe('./js/**/*', './build/safari/likeastore.safariextension/js'),
pipe('./css/**/*', './build/safari/likeastore.safariextension/css'),
pipe('./vendor/safari/browser.js', './build/safari/likeastore.safariextension/js'),
pipe('./vendor/safari/Info.plist', './build/safari/likeastore.safariextension'),
pipe('./vendor/safari/Settings.plist', './build/safari/likeastore.safariextension')
);
});
gulp.task('chrome-dist', function () {
gulp.src('./build/chrome/**/*')
.pipe(zip('chrome-extension-' + chrome.version + '.zip'))
.pipe(gulp.dest('./dist/chrome'));
});
gulp.task('firefox-dist', shell.task([
'mkdir -p dist/firefox',
'cd ./build/firefox && ../../tools/addon-sdk-1.16/bin/cfx xpi --output-file=../../dist/firefox/firefox-extension-' + firefox.version + '.xpi > /dev/null',
]));
gulp.task('safari-dist', function () {
pipe('./vendor/safari/Update.plist', './dist/safari');
});
gulp.task('firefox-run', shell.task([
'cd ./build/firefox && ../../tools/addon-sdk-1.16/bin/cfx run',
]));
gulp.task('dist', function(cb) {
return rseq('clean', ['chrome', 'firefox', 'safari'], ['chrome-dist', 'firefox-dist', 'safari-dist'], cb);
});
gulp.task('watch', function() {
gulp.watch(['./js/**/*', './css/**/*', './vendor/**/*', './img/**/*'], ['default']);
});
gulp.task('run', function (cb) {
return rseq('firefox', 'firefox-run', cb);
});
gulp.task('addons', shell.task([
'cp -R ./dist ../addons'
]));
gulp.task('default', function(cb) {
return rseq('clean', ['chrome', 'firefox', 'safari'], cb);
});