@@ -7,19 +7,26 @@ import source from 'vinyl-source-stream';
77import buffer from 'vinyl-buffer' ;
88import _ from 'lodash' ;
99
10- function bundleScript ( bundler , output , dest ) {
10+ function bundleScript ( bundler , output , dest , cb ) {
1111 function onError ( error ) {
1212 gutil . log ( gutil . colors . red ( 'Browserify Error' + error ) ) ;
1313 }
1414
15+ function onEnd ( ) {
16+ if ( cb ) {
17+ cb ( ) ;
18+ }
19+ }
20+
1521 return bundler . bundle ( )
1622 . on ( 'error' , onError )
23+ . on ( 'end' , onEnd )
1724 . pipe ( source ( output ) )
1825 . pipe ( buffer ( ) )
1926 . pipe ( gulp . dest ( dest ) ) ;
2027}
2128
22- function compileScript ( watch , opts ) {
29+ function compileScript ( watch , opts , cb ) {
2330 const acceptedOpts = _ . pick ( opts , 'paths' , 'entries' , 'noParse' , 'debug' , 'standalone' ) ;
2431 const browserifyOpts = _ . defaults ( { } , acceptedOpts , watchify . args ) ;
2532 const babelifyOpts = { comments : false } ;
@@ -44,11 +51,11 @@ function compileScript(watch, opts) {
4451 bundler . on ( 'update' , ( ) => {
4552 gutil . log ( 'Bundling ' + gutil . colors . green ( opts . output ) ) ;
4653
47- bundleScript ( bundler , opts . output , opts . dest ) ;
54+ return bundleScript ( bundler , opts . output , opts . dest , cb ) ;
4855 } ) ;
4956 }
5057
51- return bundleScript ( bundler , opts . output , opts . dest ) ;
58+ return bundleScript ( bundler , opts . output , opts . dest , cb ) ;
5259}
5360
5461const scriptHelper = {
0 commit comments