bump.js 908 B

12345678910111213141516171819202122232425262728293031
  1. var gulp = require('gulp')
  2. var gutil = require('gulp-util')
  3. var modify = require('gulp-modify-file')
  4. var moment = require('moment')
  5. // parsed command line arguments
  6. var argv = require('yargs').argv
  7. // modifies the package.json file in-place with new release-specific values.
  8. // called from the command-line.
  9. gulp.task('bump', function(done) {
  10. if (!argv.version) {
  11. gutil.log('Please specify a command line --version argument.')
  12. done(1) // error code
  13. } else {
  14. return gulp.src('package.json')
  15. .pipe(
  16. modify(function(content) {
  17. var obj = JSON.parse(content)
  18. obj.releaseDate = moment().format('YYYY-MM-DD') // always do current date
  19. obj.version = argv.version // from command line
  20. return JSON.stringify(obj, null, ' ') // indent using two spaces
  21. })
  22. )
  23. .pipe(
  24. gulp.dest('./') // overwrite itself!
  25. )
  26. }
  27. })