2017-05-23 18:44:31 +02:00
|
|
|
import * as bump from 'gulp-bump';
|
2017-05-24 00:46:34 +02:00
|
|
|
import * as gulp from 'gulp';
|
|
|
|
import * as gulpIf from 'gulp-if';
|
|
|
|
import * as gulpUtil from 'gulp-util';
|
2017-05-23 18:44:31 +02:00
|
|
|
import * as runSequence from 'run-sequence';
|
2017-05-24 00:46:34 +02:00
|
|
|
import * as yargs from 'yargs';
|
|
|
|
|
|
|
|
import { MESSAGE_BUMP_ERROR, MESSAGE_BUMP_SUCCESS } from "../consts/log";
|
2017-05-23 18:44:31 +02:00
|
|
|
|
2017-05-24 00:46:34 +02:00
|
|
|
var argv = yargs.argv;
|
2017-05-23 18:44:31 +02:00
|
|
|
|
2017-05-24 00:46:34 +02:00
|
|
|
export var taskBump = gulp.task('bump', (cb) => {
|
2017-05-23 18:44:31 +02:00
|
|
|
runSequence(
|
|
|
|
'bump-pkg-version',
|
2017-05-24 00:46:34 +02:00
|
|
|
error => {
|
2017-05-23 18:44:31 +02:00
|
|
|
if (error) {
|
2017-05-24 00:46:34 +02:00
|
|
|
console.log(gulpUtil.colors.magenta.bold('[bump]'), gulpUtil.colors.red.bold(MESSAGE_BUMP_ERROR), error);
|
2017-05-23 18:44:31 +02:00
|
|
|
} else {
|
2017-05-24 00:46:34 +02:00
|
|
|
console.log(gulpUtil.colors.magenta.bold('\n[bump]'), gulpUtil.colors.green.bold(MESSAGE_BUMP_SUCCESS));
|
2017-05-23 18:44:31 +02:00
|
|
|
}
|
|
|
|
cb(error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-05-24 00:46:34 +02:00
|
|
|
export var taskVersioning = gulp.task('bump-pkg-version', () => {
|
|
|
|
return gulp.src(['./package.json'])
|
|
|
|
.pipe(gulpIf((Object.keys(argv).length === 2), bump()))
|
|
|
|
.pipe(gulpIf(argv.patch, bump()))
|
|
|
|
.pipe(gulpIf(argv.minor, bump({ type: 'minor' })))
|
|
|
|
.pipe(gulpIf(argv.major, bump({ type: 'major' })))
|
|
|
|
.pipe(gulp.dest('./'));
|
|
|
|
});
|
|
|
|
|
|
|
|
export default { taskBump, taskVersioning };
|