Last Updated: February 25, 2016
·
2.101K
· stevelacy

Batch update repo copyrights with gulpjs

Ever had to update all your github repo license, readme, and package copyrights when the new year came around?

Why not update them all with a build system:

gulpjs (http://gulpjs.com) The streaming build system

gulpfile.js:

var gulp = require('gulp');
var git = require('gulp-git');
var replace = require('gulp-replace');

gulp.task('year', function() {
  gulp.src('./folder/LICENSE') // the location of the file to be updated
  .pipe(replace('2013', '2014')) // replace the year
  .pipe(gulp.dest('./folder')) // the file's folder
  .pipe(git.add()) // add to the file's git repo
  .pipe(git.commit('bump')) // commit message is bump
  .on('end', function(){
    git.push('origin','master'); // push it up!
  });

});

gulp.task('default', function() {
  gulp.run('year');
});

To update all your git repos:

var gulp = require('gulp');
var git = require('gulp-git');
var replace = require('gulp-replace');

gulp.task('year', function() {
  gulp.src('./*/LICENSE')
  .pipe(replace('2013', '2014'))
  .pipe(gulp.dest('./*'))
  .pipe(git.add())
  .pipe(git.commit('bump'))
  .on('end', function(){
    git.push('origin','master'); // push it up!
  });
});

gulp.task('default', function() {
  gulp.run('year');
});

You can use ./* ./*/ or other folder sequences.

More information regarding gulp: http://gulpjs.com

2 Responses
Add your response

Hello, I'm Rodolfo Dias and I'm from Brazil.

Recently I created a Gulp Web App Workflow project in my github, and I want share with you. Is a Open Source project, so feel good to contribute or use.

Have a some question? Speak with me.

url - http://rmdias.com/gulpworkflow/

over 1 year ago ·

I just noticed the gulp-git plugin today. I was trying to think of some cool uses of it and ran into this tip. +1, Really good idea!

over 1 year ago ·