bump.js 877 B

123456789101112131415161718192021222324252627282930
  1. var gulp = require('gulp');
  2. var gutil = require('gulp-util');
  3. var modify = require('gulp-modify');
  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. }
  14. else {
  15. return gulp.src('package.json')
  16. .pipe(modify({
  17. fileModifier: function(file, content) {
  18. var obj = JSON.parse(content);
  19. obj.releaseDate = moment().format('YYYY-MM-DD'); // always do current date
  20. obj.version = argv.version; // from command line
  21. return JSON.stringify(obj, null, ' '); // indent using two spaces
  22. }
  23. }))
  24. .pipe(gulp.dest('./')); // overwrite itself!
  25. }
  26. });