2014-05-14 13:47:31 +08:00
|
|
|
var gulp = require('gulp')
|
|
|
|
, clean = require('gulp-clean')
|
|
|
|
, es = require('event-stream')
|
|
|
|
, rseq = require('gulp-run-sequence')
|
2014-05-14 12:22:09 +08:00
|
|
|
|
|
|
|
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() {
|
2014-05-14 14:27:02 +08:00
|
|
|
return pipe('./tmp', [clean()])
|
2014-05-14 12:22:09 +08:00
|
|
|
})
|
|
|
|
|
2014-05-14 13:47:31 +08:00
|
|
|
gulp.task('chrome', function() {
|
2014-05-14 12:22:09 +08:00
|
|
|
return es.merge(
|
2014-05-14 14:27:02 +08:00
|
|
|
pipe('./src/lib/**/*', './tmp/chrome/lib'),
|
|
|
|
pipe('./src/icons/**/*', './tmp/chrome/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/manifest.json'], './tmp/chrome/')
|
2014-05-14 12:22:09 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2014-05-14 13:47:31 +08:00
|
|
|
gulp.task('safari', function() {
|
2014-05-14 12:22:09 +08:00
|
|
|
return es.merge(
|
2014-05-14 14:27:02 +08:00
|
|
|
pipe('./src/lib/**/*', './tmp/safari/octotree.safariextension/lib'),
|
|
|
|
pipe('./src/icons/**/*', './tmp/safari/octotree.safariextension/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/Info.plist'], './tmp/safari/octotree.safariextension/')
|
2014-05-14 12:22:09 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2014-05-14 13:47:31 +08:00
|
|
|
gulp.task('firefox', function() {
|
2014-05-14 12:22:09 +08:00
|
|
|
return es.merge(
|
2014-05-14 14:27:02 +08:00
|
|
|
pipe('./src/lib/**/*', './tmp/firefox/data/lib'),
|
|
|
|
pipe('./src/icons/**/*', './tmp/firefox/data/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/firefox.js'], './tmp/firefox/data'),
|
|
|
|
pipe('./src/package.json', './tmp/firefox')
|
2014-05-14 12:22:09 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('default', function(cb) {
|
|
|
|
return rseq('clean', ['chrome', 'safari', 'firefox'], cb)
|
2014-05-14 17:30:36 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('watch', function() {
|
2014-05-15 01:59:22 +08:00
|
|
|
gulp.watch(['./src/**/*'], ['default'])
|
2014-05-14 17:30:36 +08:00
|
|
|
})
|