@@ -250,32 +250,29 @@ if (args.notest) {
250250}
251251
252252gulp . task ( 'optimize' , optimizeTasks , function ( ) {
253- var assets = plugins . useref . assets ( ) ;
254- var cssFilter = plugins . filter ( '**/*.css' , { restore : true } ) ;
255- var jsFilter = plugins . filter ( '**/*.js' , { restore : true } ) ;
253+ var __filterCSS = plugins . filter ( '**/*.css' , { restore : true } ) ;
254+ var __filterJS = plugins . filter ( '**/*.js' , { restore : true } ) ;
256255
257256 return gulp . src ( config . build + '/index.html' )
258257 . pipe ( plugins . plumber ( ) )
259- . pipe ( assets )
260- . pipe ( cssFilter )
258+ . pipe ( plugins . useref ( ) )
259+ . pipe ( __filterCSS )
261260 . pipe ( plugins . autoprefixer ( {
262261 browsers : [ 'last 2 version' , 'safari 5' , 'ie 8' , 'ie 9' , 'opera 12.1' , 'ios 6' , 'android 4' ]
263262 } ) )
264263 . pipe ( plugins . csso ( ) )
265- . pipe ( plugins . size ( { showFiles : true , title : '[CSS] ' } ) )
266- . pipe ( cssFilter . restore )
267- . pipe ( jsFilter )
264+ . pipe ( plugins . size ( { showFiles : true , title : '»»» ' } ) )
265+ . pipe ( __filterCSS . restore )
266+ . pipe ( __filterJS )
268267 . pipe ( plugins . ngAnnotate ( ) )
269268 . pipe ( plugins . uglify ( {
270269 mangle : false ,
271270 compress : {
272271 drop_console : true
273272 }
274273 } ) )
275- . pipe ( plugins . size ( { showFiles : true , title : '[JS]' } ) )
276- . pipe ( jsFilter . restore )
277- . pipe ( assets . restore ( ) )
278- . pipe ( plugins . useref ( ) )
274+ . pipe ( plugins . size ( { showFiles : true , title : '»»»' } ) )
275+ . pipe ( __filterJS . restore )
279276 . pipe ( plugins . size ( ) )
280277 . pipe ( gulp . dest ( config . dist ) ) ;
281278} ) ;
@@ -299,7 +296,17 @@ if (args.nocoverage) {
299296
300297gulp . task ( 'test:run' , [ 'scripts' , 'styles:sass' , 'html:inject' ] , function ( done ) {
301298 cfg . singleRun = true ;
302- var server = new Server ( cfg , done ) ;
299+
300+ function karmaCompleted ( karmaResult ) {
301+ if ( karmaResult === 1 ) {
302+ done ( ) ;
303+ process . exit ( 1 ) ;
304+ } else {
305+ done ( ) ;
306+ }
307+ }
308+
309+ var server = new Server ( cfg , karmaCompleted ) ;
303310 server . start ( ) ;
304311} ) ;
305312
@@ -384,10 +391,14 @@ gulp.task('watch', function () {
384391// =============================================
385392
386393gulp . task ( 'clean:build' , function ( cb ) {
387- del ( config . build , cb ) ;
394+ del ( config . build ) . then ( function ( ) {
395+ cb ( ) ;
396+ } ) ;
388397} ) ;
389398gulp . task ( 'clean:dist' , function ( cb ) {
390- del ( config . dist , { force : true } , cb ) ;
399+ del ( config . dist , { force : true } ) . then ( function ( ) {
400+ cb ( ) ;
401+ } ) ;
391402} ) ;
392403
393404
0 commit comments