@@ -689,9 +689,16 @@ function buildDemoSass(isProductionMode) {
689
689
require ( './scripts/snapshot/snapshot.task' ) ( gulp , argv , buildConfig ) ;
690
690
691
691
// requires bundle.system to be run once
692
- gulp . task ( 'karma' , [ 'tests' ] , function ( ) {
692
+ gulp . task ( 'karma' , [ 'tests' ] , function ( done ) {
693
693
var karma = require ( 'karma' ) . server ;
694
- return karma . start ( { configFile : __dirname + '/scripts/karma/karma.conf.js' } )
694
+ karma . start ( {
695
+ configFile : __dirname + '/scripts/karma/karma.conf.js'
696
+ } , function ( result ) {
697
+ if ( result > 0 ) {
698
+ return done ( new Error ( 'Karma exited with an error' ) ) ;
699
+ }
700
+ done ( ) ;
701
+ } ) ;
695
702
} ) ;
696
703
697
704
gulp . task ( 'karma-watch' , [ 'watch.tests' , 'bundle.system' ] , function ( ) {
@@ -710,8 +717,15 @@ gulp.task('karma-watch', ['watch.tests', 'bundle.system'], function() {
710
717
* some prerelease magic (see 'prepare') and copies npm package and tooling
711
718
* files to dist.
712
719
*/
713
- gulp . task ( 'prerelease' , [ 'prepare' , 'build.release' ] , function ( done ) {
714
- runSequence ( 'package' , done ) ;
720
+ gulp . task ( 'prerelease' , function ( done ) {
721
+ runSequence (
722
+ 'tslint' ,
723
+ 'prepare' ,
724
+ 'build.release' ,
725
+ 'karma' ,
726
+ 'package' ,
727
+ done
728
+ ) ;
715
729
} ) ;
716
730
717
731
/**
@@ -723,25 +737,10 @@ gulp.task('release', ['publish.npm', 'publish.github']);
723
737
* Pulls latest, ensures there are no unstaged/uncommitted changes, updates
724
738
* package.json minor version and generates CHANGELOG for release.
725
739
*/
726
- gulp . task ( 'prepare' , function ( ) {
727
- var execSync = require ( 'child_process' ) . execSync ;
728
- var spawnSync = require ( 'child_process' ) . spawnSync ;
740
+ gulp . task ( 'prepare' , [ 'git-pull-latest' ] , function ( ) {
729
741
var semver = require ( 'semver' ) ;
730
742
var fs = require ( 'fs' ) ;
731
743
var changelog = require ( 'gulp-conventional-changelog' ) ;
732
- var self = this ;
733
-
734
- //Check for uncommitted changes
735
- var gitStatusResult = execSync ( 'git status --porcelain' ) ;
736
- if ( gitStatusResult . toString ( ) . length > 0 ) {
737
- return fail ( 'You have uncommitted changes, please stash or commit them before running prepare' ) ;
738
- }
739
-
740
- //Pull latest
741
- var gitPullResult = spawnSync ( 'git' , [ 'pull' , 'origin' , '2.0' ] ) ;
742
- if ( gitPullResult . status !== 0 ) {
743
- fail ( 'There was an error running \'git pull\':\n' + gitPullResult . stderr . toString ( ) ) ;
744
- }
745
744
746
745
//Update package.json version
747
746
var packageJSON = require ( './package.json' ) ;
@@ -754,15 +753,31 @@ gulp.task('prepare', function(){
754
753
preset : 'angular'
755
754
} ) )
756
755
. pipe ( gulp . dest ( './' ) ) ;
756
+ } ) ;
757
757
758
758
759
- function fail ( msg ) {
759
+ gulp . task ( 'git-pull-latest' , function ( ) {
760
+ var execSync = require ( 'child_process' ) . execSync ;
761
+ var spawnSync = require ( 'child_process' ) . spawnSync ;
762
+
763
+ function fail ( context , msg ) {
760
764
// remove gulp's 'Finished 'task' after 10ms' message
761
- self . removeAllListeners ( 'task_stop' ) ;
765
+ context . removeAllListeners ( 'task_stop' ) ;
762
766
console . error ( 'Prepare aborted.' ) ;
763
767
console . error ( msg ) ;
764
768
}
765
769
770
+ //Check for uncommitted changes
771
+ var gitStatusResult = execSync ( 'git status --porcelain' ) ;
772
+ if ( gitStatusResult . toString ( ) . length > 0 ) {
773
+ return fail ( this , 'You have uncommitted changes, please stash or commit them before running prepare' ) ;
774
+ }
775
+
776
+ //Pull latest
777
+ var gitPullResult = spawnSync ( 'git' , [ 'pull' , 'origin' , '2.0' ] ) ;
778
+ if ( gitPullResult . status !== 0 ) {
779
+ fail ( 'There was an error running \'git pull\':\n' + gitPullResult . stderr . toString ( ) ) ;
780
+ }
766
781
} ) ;
767
782
768
783
/**
@@ -843,11 +858,14 @@ gulp.task('publish.npm', function(done) {
843
858
} ) ;
844
859
} ) ;
845
860
861
+ gulp . task ( 'publish.nightly' , [ 'build.release' ] , function ( done ) {
862
+ runSequence ( 'git-pull-latest' , 'nightly' , done ) ;
863
+ } ) ;
846
864
847
865
/**
848
866
* Publishes a new tag to npm with a nightly tag.
849
867
*/
850
- gulp . task ( 'publish. nightly' , function ( done ) {
868
+ gulp . task ( 'nightly' , [ 'package' ] , function ( done ) {
851
869
var fs = require ( 'fs' ) ;
852
870
var spawn = require ( 'child_process' ) . spawn ;
853
871
var packageJSON = require ( './package.json' ) ;
@@ -872,6 +890,8 @@ gulp.task('publish.nightly', function(done) {
872
890
. concat ( createUniqueHash ( ) )
873
891
. join ( '-' ) ;
874
892
893
+ fs . writeFileSync ( './package.json' , JSON . stringify ( packageJSON , null , 2 ) ) ;
894
+
875
895
var npmCmd = spawn ( 'npm' , [ 'publish' , '--tag=nightly' , './dist' ] ) ;
876
896
877
897
npmCmd . stdout . on ( 'data' , function ( data ) {
@@ -925,11 +945,11 @@ gulp.task('tooling', function(){
925
945
/**
926
946
* TS LINT
927
947
*/
928
- gulp . task ( " tslint" , function ( ) {
929
- var tslint = require ( " gulp-tslint" ) ;
930
- gulp . src ( [
931
- 'ionic/**/*.ts' ,
932
- '!ionic/**/test/**/*' ,
933
- ] ) . pipe ( tslint ( ) )
934
- . pipe ( tslint . report ( 'verbose' ) ) ;
948
+ gulp . task ( ' tslint' , function ( done ) {
949
+ var tslint = require ( ' gulp-tslint' ) ;
950
+ return gulp . src ( [
951
+ 'ionic/**/*.ts' ,
952
+ '!ionic/**/test/**/*' ,
953
+ ] ) . pipe ( tslint ( ) )
954
+ . pipe ( tslint . report ( 'verbose' ) ) ;
935
955
} ) ;
0 commit comments