Skip to content

Commit 4375094

Browse files
committed
Refactor gulp-file.
1 parent e83e1e1 commit 4375094

File tree

1 file changed

+40
-29
lines changed

1 file changed

+40
-29
lines changed

gulpfile.js

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,13 @@ var runSequence = require('run-sequence');
2323

2424
gulp.task('default', ["test"]);
2525

26-
/** Build all-in-one files for use in the browser */
27-
gulp.task('browser', function () {
26+
gulp.task('browser', function(cb){
27+
runSequence('build-browser-test', 'build-browser', cb);
28+
})
2829

30+
/** Build all-in-one files for use in the browser */
31+
gulp.task('build-browser', function () {
2932
var browserOutput = 'build/browser';
30-
var testFiles = [];
31-
gulp.src('./test/**/*.test.js')
32-
.pipe( through.obj( function( file, enc, cb ) {
33-
testFiles.push( file.path );
34-
cb();
35-
}, function(cb) {
36-
// At end-of-stream, push the list of files to the next step
37-
this.push( testFiles );
38-
cb();
39-
}))
40-
.pipe( through.obj( function( testFiles, enc, cb) {
41-
browserify({
42-
entries: testFiles,
43-
cache: {},
44-
debug: true
45-
}).transform(babelify.configure({
46-
ignore: /external/
47-
}))
48-
.bundle()
49-
.on('error', gutil.log)
50-
.pipe(source('neo4j-web.test.js'))
51-
.pipe(buffer())
52-
.pipe(uglify())
53-
.pipe(gulp.dest(browserOutput));
54-
}));
55-
56-
5733
// Our app bundler
5834
var appBundler = browserify({
5935
entries: ['lib/neo4j.js'],
@@ -78,6 +54,41 @@ gulp.task('browser', function () {
7854
.pipe(gulp.dest(browserOutput));
7955
});
8056

57+
gulp.task('build-browser-test', function(){
58+
var browserOutput = 'build/browser';
59+
var testFiles = [];
60+
return gulp.src('./test/**/*.test.js')
61+
.pipe( through.obj( function( file, enc, cb ) {
62+
testFiles.push( file.path );
63+
cb();
64+
}, function(cb) {
65+
// At end-of-stream, push the list of files to the next step
66+
this.push( testFiles );
67+
cb();
68+
}))
69+
.pipe( through.obj( function( testFiles, enc, cb) {
70+
browserify({
71+
entries: testFiles,
72+
cache: {},
73+
debug: true
74+
}).transform(babelify.configure({
75+
ignore: /external/
76+
}))
77+
.bundle(function(err, res){
78+
cb();
79+
})
80+
.on('error', gutil.log)
81+
.pipe(source('neo4j-web.test.js'))
82+
.pipe(buffer())
83+
.pipe(uglify())
84+
.pipe(gulp.dest(browserOutput))
85+
},
86+
function(cb) {
87+
cb()
88+
}
89+
));
90+
});
91+
8192
var compress = function(source, dest, filename) {
8293

8394
}

0 commit comments

Comments
 (0)