8
0

bump-year.js 966 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. const gulp = require( 'gulp' );
  7. const path = require( 'path' );
  8. const replace = require( 'gulp-replace' );
  9. const filterGitignore = require( '../utils/filtergitignore' );
  10. // Change this to correct year.
  11. const year = '2017';
  12. /**
  13. * Replaces license date in source files with new date.
  14. *
  15. * Example (remember to change the year harcoded in the module):
  16. *
  17. * gulp exec --task bump-year
  18. *
  19. * @param {String} workdir
  20. * @returns {Stream}
  21. */
  22. module.exports = function executeBumpYear( workdir ) {
  23. const licenseRegexp = /(@license Copyright \(c\) 2003-)[0-9]{4}(, CKSource - Frederico Knabben\.)/g;
  24. const glob = path.join( workdir, '**/*' );
  25. return gulp.src( glob )
  26. .pipe( filterGitignore() )
  27. .pipe( replace(
  28. licenseRegexp,
  29. `$1${ year }$2`,
  30. { skipBinary: true }
  31. ) )
  32. .pipe( gulp.dest( workdir ) );
  33. };