-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·95 lines (78 loc) · 2.9 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
var gulp = require('gulp');
var clean = require('gulp-clean');
var include = require('gulp-include');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
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('default', function(cb) {
return rseq('clean', ['chrome', 'firefox', 'safari'], cb);
});
gulp.task('clean', function() {
return pipe('./build', [clean()]);
});
gulp.task('watch', function() {
gulp.watch(['./js/**/*', './css/**/*', './html/**/*', './vendor/**/*', './img/**/*'], ['default']);
});
gulp.task('chrome', function() {
var build_path = './build/chrome';
es.merge(
pipe('./img/**/*', build_path + '/img'),
pipe('./css/**/*', build_path + '/css'),
pipe('./html/**/*', build_path),
pipe('./vendor/chrome/manifest.json', build_path)
);
gulp.src('js/hnprofile.js')
.pipe(include())
.pipe(insert.prepend("var HNProfileBrowser = 'chrome';\n"))
.pipe(gulp.dest(build_path + '/js'));
});
gulp.task('firefox', function() {
var build_path = './build/firefox';
es.merge(
pipe('./img/**/*', build_path + '/data/img'),
pipe('./css/**/*', build_path + '/data/css'),
pipe('./html/**/*', build_path + '/data'),
pipe('./vendor/firefox/main.js', build_path + '/data'),
pipe('./vendor/firefox/package.json', build_path)
);
gulp.src('js/hnprofile.js')
.pipe(include())
.pipe(insert.prepend("var HNProfileBrowser = 'firefox';\n"))
.pipe(gulp.dest(build_path + '/data/js'));
});
gulp.task('safari', function() {
var build_path = './build/safari/hnprofile.safariextension';
es.merge(
pipe('./img/**/*', build_path + '/img'),
pipe('./css/**/*', build_path + '/css'),
pipe('./html/**/*', build_path),
pipe('./vendor/safari/Info.plist', build_path),
pipe('./vendor/safari/Settings.plist', build_path)
);
gulp.src('img/icon/128.png')
.pipe(rename("Icon.png"))
.pipe(gulp.dest(build_path))
gulp.src('js/hnprofile.js')
.pipe(include())
.pipe(insert.prepend("var HNProfileBrowser = 'safari';\n"))
.pipe(gulp.dest(build_path + '/js'));
});