@@ -13,57 +13,50 @@ var header = require('gulp-header');
1313var sourceMaps = require ( 'gulp-sourcemaps' ) ;
1414
1515var buildConfig = {
16- outputPath : 'dist' ,
17- pkg : require ( './package.json' ) ,
18- banner : [
19- '/*!' ,
20- ' * Knockout Mapping plugin v<%= pkg.version %>' ,
21- ' * (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/' ,
22- ' * License: MIT (http://www.opensource.org/licenses/mit-license.php)' ,
23- ' */\n'
24- ] . join ( '\n' )
16+ outputPath : 'dist' ,
17+ pkg : require ( './package.json' ) ,
18+ banner : [
19+ '/*!' ,
20+ ' * Knockout Mapping plugin v<%= pkg.version %>' ,
21+ ' * (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/' ,
22+ ' * License: MIT (http://www.opensource.org/licenses/mit-license.php)' ,
23+ ' */\n'
24+ ] . join ( '\n' )
2525} ;
2626
2727
28- gulp . task ( 'clear' , function ( ) {
29- del . sync ( '*' , { cwd : 'dist' } ) ;
28+ gulp . task ( 'clear' , function ( ) {
29+ return del ( '*' , { cwd : 'dist' } ) ;
3030} ) ;
3131
32- gulp . task ( 'build' , function ( ) {
33- return gulp . src ( 'knockout.mapping.js' )
34- . pipe ( plumber ( ) )
35- . pipe ( jshint ( ) )
36- . pipe ( jshint . reporter ( 'jshint-stylish' ) )
37- . pipe ( header ( buildConfig . banner , { pkg : buildConfig . pkg } ) )
38- . pipe ( gulp . dest ( buildConfig . outputPath ) )
39- . pipe ( rename ( 'knockout.mapping.min.js' ) )
40- . pipe ( replace ( / ( : ? v a r \s * ?D E B U G \s * ?= \s * ?t r u e ) / , 'const DEBUG=false' ) )
41- . pipe ( sourceMaps . init ( ) )
42- . pipe ( uglify ( { preserveComments : 'some' } ) )
43- . pipe ( sourceMaps . write ( './' ) )
44- . pipe ( gulp . dest ( buildConfig . outputPath ) ) ;
32+ gulp . task ( 'build' , function ( ) {
33+ return gulp . src ( 'knockout.mapping.js' )
34+ . pipe ( plumber ( { errorHandler : process . env . NODE_ENV === 'development' } ) )
35+ . pipe ( jshint ( ) ) . pipe ( jshint . reporter ( 'jshint-stylish' ) )
36+ . pipe ( header ( buildConfig . banner , { pkg : buildConfig . pkg } ) )
37+ . pipe ( gulp . dest ( buildConfig . outputPath ) )
38+ . pipe ( rename ( 'knockout.mapping.min.js' ) )
39+ . pipe ( replace ( / ( : ? v a r \s * ?D E B U G \s * ?= \s * ?t r u e ) / , 'var DEBUG=false' ) )
40+ . pipe ( sourceMaps . init ( ) )
41+ . pipe ( uglify ( ) )
42+ . pipe ( sourceMaps . write ( './' ) )
43+ . pipe ( gulp . dest ( buildConfig . outputPath ) ) ;
4544} ) ;
4645
47- gulp . task ( 'test' , [ 'test- jshint'] , function ( ) {
48- return gulp . src ( ' spec/spec-runner.htm' )
49- . pipe ( plumber ( ) )
50- . pipe ( qunit ( ) ) ;
46+ gulp . task ( 'jshint' , function ( ) {
47+ return gulp . src ( [ 'knockout.mapping.js' , ' spec/*.js' ] )
48+ . pipe ( jshint ( ) )
49+ . pipe ( jshint . reporter ( 'jshint-stylish' ) ) ;
5150} ) ;
5251
53- gulp . task ( 'test-ci' , function ( ) {
54- return gulp . src ( 'spec/spec-runner-*.htm' , { read :false } )
55- . pipe ( qunit ( ) ) ;
56- } ) ;
57-
58- gulp . task ( 'test-jshint' , function ( ) {
59- return gulp . src ( 'spec/*.js' )
60- . pipe ( jshint ( ) )
61- . pipe ( jshint . reporter ( 'jshint-stylish' ) ) ;
62- } ) ;
52+ gulp . task ( 'test' , gulp . series ( 'build' , 'jshint' , function ( ) {
53+ return gulp . src ( process . env . CI ? 'spec/spec-runner-*.htm' : 'spec/spec-runner.htm' )
54+ . pipe ( plumber ( { errorHandler : process . env . NODE_ENV === 'development' } ) )
55+ . pipe ( qunit ( { timeout : 30 } ) ) ;
56+ } ) ) ;
6357
64- gulp . task ( 'default' , [ 'clear' , 'build' , ' test'] ) ;
58+ gulp . task ( 'default' , gulp . series ( 'clear' , 'test' ) ) ;
6559
66- gulp . task ( 'watch' , function ( ) {
67- gulp . watch ( 'knockout.mapping.js' , [ 'clear' , 'build' ] ) ;
68- gulp . watch ( [ 'spec/spec-runner.htm' , 'spec/*.js' ] , [ 'test' ] ) ;
60+ gulp . task ( 'watch' , function ( ) {
61+ gulp . watch ( [ 'knockout.mapping.js' , 'spec/spec-runner.htm' , 'spec/*.js' ] , gulp . series ( 'clear' , 'test' ) ) ;
6962} ) ;
0 commit comments