@@ -4,10 +4,14 @@ var gulp = require('gulp'),
44 browserify = require ( 'gulp-browserify' ) ,
55 concat = require ( 'gulp-concat' ) ,
66 mocha = require ( 'gulp-mocha' ) ,
7- shell = require ( 'gulp-shell ' ) ,
7+ shell = require ( 'shelljs ' ) ,
88 del = require ( 'del' ) ,
99 jshint = require ( 'gulp-jshint' ) ,
10- stylish = require ( 'jshint-stylish' ) ;
10+ stylish = require ( 'jshint-stylish' ) ,
11+ semver = require ( 'semver' ) ,
12+ jsonfile = require ( 'jsonfile' ) ,
13+ inquirer = require ( "inquirer" ) ,
14+ fs = require ( 'fs' ) ;
1115
1216gulp . task ( 'clean' , function ( cb ) {
1317 del ( 'lib/**/*.*' , cb ) ;
@@ -42,9 +46,9 @@ gulp.task('test', function () {
4246 . pipe ( mocha ( { reporter : 'spec' , bail : true , globals : { should : require ( 'should' ) } } ) ) ;
4347} ) ;
4448
45- gulp . task ( 'bench' , shell . task ( [
46- 'node benchmark/benchmark.js'
47- ] ) ) ;
49+ gulp . task ( 'bench' , function ( ) {
50+ shell . exec ( 'node benchmark/benchmark.js' ) ;
51+ } ) ;
4852
4953gulp . task ( 'lint' , function ( ) {
5054 return gulp . src ( './src/**/*.js' )
@@ -53,5 +57,48 @@ gulp.task('lint', function() {
5357 . pipe ( jshint . reporter ( 'fail' ) ) ;
5458} ) ;
5559
60+ gulp . task ( 'release' , [ 'compile' ] , function ( cb ) {
61+ inquirer . prompt ( {
62+ type : 'list' ,
63+ name : 'bumpType' ,
64+ message : 'Which version do you want to bump?' ,
65+ choices : [ 'patch' , 'minor' , 'major' ] ,
66+ //default is patch
67+ default : 0
68+ } , function ( result ) {
69+ var f = jsonfile . readFileSync ( './package.json' ) ;
70+ f . version = semver . inc ( f . version , result . bumpType ) ;
71+ jsonfile . writeFileSync ( './package.json' , f ) ;
72+
73+ shell . exec ( 'git add .' ) ;
74+ shell . exec ( 'git commit -m "Bumping version to ' + f . version + '"' ) ;
75+ shell . exec ( 'git push origin master' ) ;
76+ shell . exec ( 'git tag -a ' + f . version + ' -m "Creating tag for version ' + f . version + '"' ) ;
77+ shell . exec ( 'git push origin ' + f . version ) ;
78+ shell . exec ( 'npm publish' ) ;
79+
80+ shell . exec ( 'git clone https://github.com/imor/pathfinding-bower.git release' ) ;
81+ process . chdir ( 'release' ) ;
82+ fs . writeFileSync ( 'pathfinding-browser.js' , fs . readFileSync ( '../lib/pathfinding-browser.js' ) ) ;
83+ fs . writeFileSync ( 'pathfinding-browser.min.js' , fs . readFileSync ( '../lib/pathfinding-browser.min.js' ) ) ;
84+
85+ f = jsonfile . readFileSync ( 'bower.json' ) ;
86+ f . version = semver . inc ( f . version , result . bumpType ) ;
87+ jsonfile . writeFileSync ( 'bower.json' , f ) ;
88+
89+ shell . exec ( 'git add .' ) ;
90+ shell . exec ( 'git commit -m "Bumping version to ' + f . version + '"' ) ;
91+ shell . exec ( 'git push origin master' ) ;
92+ shell . exec ( 'git tag -a ' + f . version + ' -m "Creating tag for version ' + f . version + '"' ) ;
93+ shell . exec ( 'git push origin ' + f . version ) ;
94+
95+ process . chdir ( '../' ) ;
96+ del ( 'release' ) ;
97+ del ( 'lib/**/*.*' , cb ) ;
98+
99+ cb ( ) ;
100+ } ) ;
101+ } ) ;
102+
56103gulp . task ( 'default' , [ 'lint' , 'test' , 'compile' ] , function ( ) {
57104} ) ;
0 commit comments