Skip to content

Commit dc62f5f

Browse files
committed
Add release task to gulpfile
1 parent 8dfd874 commit dc62f5f

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

gulpfile.js

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1216
gulp.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

4953
gulp.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+
56103
gulp.task('default', ['lint', 'test', 'compile'], function() {
57104
});

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@
1919
"heap": "0.2.5"
2020
},
2121
"devDependencies": {
22+
"colors": "^1.0.3",
2223
"del": "^0.1.3",
2324
"gulp": "^3.8.10",
2425
"gulp-browserify": "^0.5.0",
2526
"gulp-concat": "^2.4.1",
2627
"gulp-jshint": "^1.9.0",
2728
"gulp-mocha": "^2.0.0",
2829
"gulp-rename": "^1.2.0",
29-
"gulp-shell": "^0.2.10",
3030
"gulp-uglify": "^1.0.1",
31+
"inquirer": "^0.8.0",
3132
"jshint-stylish": "^1.0.0",
33+
"jsonfile": "^2.0.0",
3234
"mocha": "2.0.x",
35+
"semver": "^4.2.0",
36+
"shelljs": "^0.3.0",
3337
"should": "4.3.x"
3438
},
3539
"scripts": {

0 commit comments

Comments
 (0)