-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (44 loc) · 1.23 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var gulp = require('gulp'),
bump = require('gulp-bump'),
git = require('gulp-git'),
npm = require('npm'),
prompt = require('gulp-prompt');
gulp.task('bump', function (cb) {
var versionType = 'major';
gulp.src(['.']).pipe(
prompt.prompt({
type: 'list',
name: 'bump',
message: 'What type of bump would you like to do?',
choices: ['patch', 'minor', 'major']
}, function(res){
versionType = res.bump;
gulp.src(['./package.json'])
.pipe(bump({type: versionType}))
.pipe(gulp.dest('./'))
.on('end', function(){
cb();
});
}));
});
gulp.task('publish-git', ['bump'], function (cb) {
var pkg = require('./package.json');
var msg = 'Bumps version '+pkg.version;
gulp.src('./*.json')
.pipe(git.add())
.pipe(git.commit(msg))
.pipe(git.tag('v'+pkg.version, msg, function(){
git.push('origin', 'master', { args: '--tags' }, function(){
cb();
});
}));
});
gulp.task('publish-npm', ['publish-git'], function(cb) {
npm.load({}, function(error) {
if (error) return console.error(error);
npm.commands.publish(['.'], function(error) {
if (error) return console.error(error);
cb();
});
});
});