forked from mozilla-bteam/bz.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
38 lines (33 loc) · 1.09 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
var fs = require("fs");
var gulp = require("gulp");
var babel = require("gulp-babel");
var browserify = require("browserify");
var babelify = require("babelify");
var source = require('vinyl-source-stream');
// metadata
var pkgInfo = require('./package.json');
gulp.task("browser", function() {
browserify({
debug: true
})
.transform(babelify)
.require('./src/bz.js', { entry: true })
.bundle()
.on("error", function (err) { console.log("Error: " + err.message); })
.pipe(source('bz.js'))
.pipe(gulp.dest('./build/browser'));
});
gulp.task("node", function () {
return gulp.src(['./src/index.js', './src/xhr.js'])
.pipe(babel())
.pipe(gulp.dest("build/node"));
});
gulp.task("watch", function() {
return gulp.watch('./src/*.js', ['default']);
});
gulp.task("default", ["browser", "node"], function() {
// copy files
console.log("copying files...");
fs.createReadStream('./build/browser/bz.js').pipe(fs.createWriteStream('./test/browser/files/bz.js'));
fs.createReadStream('./build/browser/bz.js').pipe(fs.createWriteStream('./bz-'+pkgInfo.version+'.js'));
});