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
|
|
|
|
|
|
|
// helpers
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// tasks
|
|
|
|
gulp.task('clean', function() {
|
|
|
|
return pipe('./dist', [clean()])
|
|
|
|
})
|
|
|
|
|
2014-05-14 13:47:31 +08:00
|
|
|
gulp.task('chrome', function() {
|
2014-05-14 12:22:09 +08:00
|
|
|
return es.merge(
|
|
|
|
pipe('./src/lib/**/*', './dist/chrome/lib'),
|
|
|
|
pipe('./src/icons/**/*', './dist/chrome/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/manifest.json'], './dist/chrome/')
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2014-05-14 13:47:31 +08:00
|
|
|
gulp.task('safari', function() {
|
2014-05-14 12:22:09 +08:00
|
|
|
return es.merge(
|
|
|
|
pipe('./src/lib/**/*', './dist/safari/octotree.safariextension/lib'),
|
|
|
|
pipe('./src/icons/**/*', './dist/safari/octotree.safariextension/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/Info.plist'], './dist/safari/octotree.safariextension/')
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
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 13:47:31 +08:00
|
|
|
pipe('./src/lib/**/*', './dist/firefox/data/lib'),
|
|
|
|
pipe('./src/icons/**/*', './dist/firefox/data/icons'),
|
|
|
|
pipe(['./src/inject.js', './src/inject.css', './src/firefox.js'], './dist/firefox/data'),
|
|
|
|
pipe('./src/package.json', './dist/firefox')
|
2014-05-14 12:22:09 +08:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('default', function(cb) {
|
|
|
|
return rseq('clean', ['chrome', 'safari', 'firefox'], cb)
|
|
|
|
})
|