forked from anvaka/VivaGraphJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (38 loc) · 1.05 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var del = require('del');
var run = require('gulp-run');
gulp.task('clean', clean);
gulp.task('build', build);
gulp.task('test', test);
gulp.task('release', ['clean', 'build'], test);
gulp.task('default', watch);
function watch() {
gulp.watch('src/**/*.js', ['build']);
}
function clean(cb) {
del(['dist'], cb);
}
function test() {
new run.Command('npm test').exec();
}
function build() {
var bundler = require('browserify')('./src/viva.js', {
standalone: 'Viva'
});
var bundle = bundler.bundle()
.on('error', showError);
bundle.pipe(source('vivagraph.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/'))
.pipe(rename('vivagraph.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
function showError(err) {
gutil.log(gutil.colors.red('Failed to browserify'), gutil.colors.yellow(err.message));
}
}