forked from mixtube/mixtube-playback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (58 loc) · 1.67 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
'use strict';
var path = require('path'),
gulp = require('gulp'),
gutil = require('gulp-util'),
source = require('vinyl-source-stream'),
watchify = require('watchify'),
browserify = require('browserify'),
browserSync = require('browser-sync'),
watch = require('gulp-watch'),
jshint = require('gulp-jshint');
function installWatchify(src, dest) {
var bundler = watchify(
browserify(src,
{
cache: {},
packageCache: {},
fullPaths: true,
debug: true
}));
bundler.on('update', function() {
gutil.log('Bundle "' + src + '" updated');
reBundle();
});
function reBundle() {
return bundler.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source(path.basename(dest)))
.pipe(gulp.dest(path.dirname(dest)));
}
return reBundle();
}
gulp.task('watch', function() {
[
'integration/playbackSpec'
].forEach(function(partialPath) {
installWatchify(
'./src/test/' + partialPath + '.js',
'./build/test/' + partialPath + '.bundle.js');
});
gulp.src(['src/main/**/*.js', 'src/test/**/*.js'])
.pipe(watch(['src/main/**/*.js', 'src/test/**/*.js']))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
// run a local server for integration tests (manual)
gulp.task('serve', ['watch'], function() {
var baseDirs = ['src/test/integration/web', 'build/test/integration'];
browserSync({
open: false,
server: {
baseDir: baseDirs.concat(['node_modules/jasmine-core'])
}
});
gulp.watch(baseDirs.map(function(baseDir) {
return baseDir + '/**/*';
}), browserSync.reload);
});
gulp.task('default', ['serve']);