Gulp - recompile the revised version for tagging

Regarding the question that I have with gulp -tag-version , there README suggests:

function inc(importance) {
    // get all the files to bump version in
    return gulp.src(['./package.json', './bower.json']) 
        // bump the version number in those files
        .pipe(bump({type: importance}))
        // save it back to filesystem
        .pipe(gulp.dest('./'))

        /*  Recompile the Javascript here */

        // commit the changed version number
        .pipe(git.commit('bumps package version')) 
        // read only one file to get the version number
        .pipe(filter('package.json'))
        // **tag it in the repository**
        .pipe(tag_version()) 
}

gulp.task('patch', function() { return inc('patch'); })
gulp.task('feature', function() { return inc('minor'); })
gulp.task('release', function() { return inc('major'); })

I would like to recompile Javascript between the download version and the git tag. I have a task for this, jsbut it is not clear how you can call the task js(or otherwise reorder the bump / tag tasks) to fulfill this general and desired result (i.e. have a version in the headers of your compiled code).

Also worth noting is that if you had three objectives bump, compileand tag, bump package.jsonit seems, is cached and re-read a separate tagtask.

+4
1

- 3 , :

  • tag commit, ,
  • commit js,
  • js bump, , -
  • bump .

, js, bump, , , watch .

, - run-sequence, .

gulp, , inc, , ( --major, --minor, --patch).

, - ( ):

gulp.task('uprev', function () {
  return gulp.src(['./package.json', './bower.json'])
    .pipe(bump({ type: process.argv[3] ? process.argv[3].substr(2) : 'patch' }))
    .pipe(gulp.dest('./'));
});

gulp.task('rebuild', function (cb) {
  runSequence('uprev', 'js', cb); //uprev will here be executed before js
});

gulp.task('commit', ['rebuild'], function () {
    return gulp.src(['./package.json', './bower.json', 'dist/**/*'])
      .pipe(git.add())
      .pipe(git.commit('bump version'));
});

gulp.task('bump', ['commit'], function () {
  return gulp.src('package.json')
    .pipe(tagVersion());
});

, , dist .

bump commit, gulp -filter, , , .

() gulp -tag- node fs- gulp - git :

gulp.task('bump', ['commit'], function (cb) {
  fs.readFile('./package.json', function (err, data) {
    if (err) { return cb(err); }
    var version = JSON.parse(data.toString()).version;
    git.tag(version, 'Version message', function (err) {
      cb(err);
    });
});
+7

All Articles