-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d3e8f6
commit 7aab780
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var gulp = require('gulp'), | ||
bump = require('gulp-bump'), | ||
gutil = require('gulp-util'), | ||
git = require('gulp-git'), | ||
minimist = require('minimist'), | ||
semver = require('semver'); | ||
|
||
var paths = require('./paths'); | ||
|
||
function getPackageJsonVersion() { | ||
//We parse the json file instead of using require because require caches multiple calls so the version number won't be updated | ||
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; | ||
}; | ||
|
||
gulp.task('version-bump', function () { | ||
var args = minimist(process.argv); | ||
|
||
var ver = args._.pop(); | ||
var options = {}; | ||
if (semver.valid(ver)) options.version = ver; | ||
else options.type = ver; | ||
|
||
return gulp.src(['./package.json']) | ||
.pipe(bump(options).on('error', gutil.log)) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
|
||
gulp.task('version-commit', function () { | ||
var version = getPackageJsonVersion(); | ||
return gulp.src('.') | ||
.pipe(git.commit('Version ' + version, { args: '-a' })); | ||
}); | ||
|
||
gulp.task('version-push', function (cb) { | ||
git.push('origin', 'master', cb); | ||
}); | ||
|
||
gulp.task('version-tag', function (cb) { | ||
var version = getPackageJsonVersion(); | ||
git.tag(version, 'Version ' + version, function (error) { | ||
if (error) { | ||
return cb(error); | ||
} | ||
git.push('origin', 'master', { args: '--tags' }, cb); | ||
}); | ||
}); | ||
|
||
gulp.task('version', function (callback) { | ||
runSequence( | ||
'version-bump', | ||
'version-commit', | ||
'version-push', | ||
'version-tag', | ||
function (error) { | ||
if (error) { | ||
console.log(error.message); | ||
} else { | ||
console.log('Version set and comitted successfully'); | ||
} | ||
callback(error); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters