@@ -70,21 +70,39 @@ function _bundle(pathToIndex, pathToBundle, opts) {
70
70
opts = opts || { } ;
71
71
72
72
// do we output a minified file?
73
- var outputMinified = ! ! opts . pathToMinBundle && ! opts . debug ;
73
+ var pathToMinBundle = opts . pathToMinBundle ,
74
+ outputMinified = ! ! pathToMinBundle && ! opts . debug ;
74
75
75
76
var browserifyOpts = { } ;
76
77
browserifyOpts . standalone = opts . standalone ;
77
78
browserifyOpts . debug = opts . debug ;
78
79
browserifyOpts . transform = outputMinified ? [ compressAttributes ] : [ ] ;
79
80
80
- browserify ( pathToIndex , browserifyOpts ) . bundle ( function ( err , buf ) {
81
+ var b = browserify ( pathToIndex , browserifyOpts ) ,
82
+ bundleWriteStream = fs . createWriteStream ( pathToBundle ) ;
83
+
84
+ bundleWriteStream . on ( 'finish' , function ( ) {
85
+ logger ( pathToBundle ) ;
86
+ } ) ;
87
+
88
+ b . bundle ( function ( err , buf ) {
81
89
if ( err ) throw err ;
82
90
83
91
if ( outputMinified ) {
84
92
var minifiedCode = UglifyJS . minify ( buf . toString ( ) , constants . uglifyOptions ) . code ;
85
93
86
- fs . writeFile ( opts . pathToMinBundle , minifiedCode ) ;
94
+ fs . writeFile ( pathToMinBundle , minifiedCode , function ( err ) {
95
+ if ( err ) throw err ;
96
+
97
+ logger ( pathToMinBundle ) ;
98
+ } ) ;
87
99
}
88
100
} )
89
- . pipe ( fs . createWriteStream ( pathToBundle ) ) ;
101
+ . pipe ( bundleWriteStream ) ;
102
+ }
103
+
104
+ function logger ( pathToOutput ) {
105
+ var log = 'ok ' + path . basename ( pathToOutput ) ;
106
+
107
+ console . log ( log ) ;
90
108
}
0 commit comments