瀏覽代碼

Replaces license header date. Limited to one repository for testing purposes

Maksymilian Barnaś 9 年之前
父節點
當前提交
1695ce1348
共有 2 個文件被更改,包括 17 次插入7 次删除
  1. 14 7
      dev/tasks/exec/functions/bump-year.js
  2. 3 0
      dev/tasks/exec/tasks/exec.js

+ 14 - 7
dev/tasks/exec/functions/bump-year.js

@@ -8,13 +8,11 @@
 const gulp = require( 'gulp' );
 const through = require( 'through2' );
 const path = require( 'path' );
-// const gitignore = require( 'gulp-gitignore' );
-
 const filter = require( 'gulp-filter' );
 const gitignore = require( 'parse-gitignore' );
 const fs = require( 'fs' );
-
 const PassThrough = require( 'stream' ).PassThrough;
+const replace = require( 'gulp-replace' );
 
 function filterGitignore() {
 	const fp = '.gitignore';
@@ -24,7 +22,9 @@ function filterGitignore() {
 	}
 
 	let glob = gitignore( fp );
-	let inverted = glob.map( pattern => pattern.startsWith( '!' ) ? pattern.slice( 1 ) : '!' + pattern );
+	let inverted = glob.map(
+		pattern => pattern.startsWith( '!' ) ? pattern.slice( 1 ) : '!' + pattern
+	);
 	inverted.unshift( '**/*' );
 
 	return filter( inverted );
@@ -35,17 +35,24 @@ function filterGitignore() {
  */
 module.exports = ( workdir ) => {
 	const glob = path.join( workdir, '**/*' );
+	const reLicense = /(@license Copyright \(c\) 2003-)[0-9]{4}/g;
+	const yearReplacement = '$12017';
 
 	let fileCount = 0;
 
 	return gulp.src( glob )
 		.pipe( filterGitignore() )
-		.pipe( through.obj( ( file, enc, cb ) => {
+		.pipe( replace(
+			reLicense,
+			yearReplacement,
+			{ skipBinary: true }
+		) )
+		.pipe( through.obj( ( file, enc, next ) => {
 			fileCount++;
-			// console.log( file.path );
 
-			cb( );
+			next( null, file );
 		} ) )
+		.pipe( gulp.dest( workdir ) )
 		.on( 'end', ( ) => {
 			console.log( 'File count:', fileCount );
 		} );

+ 3 - 0
dev/tasks/exec/tasks/exec.js

@@ -48,6 +48,9 @@ module.exports = ( execTask, ckeditor5Path, packageJSON, workspaceRoot, dryRun )
 						}
 					}
 				}
+
+				// FIXME stop after first repository
+				return;
 			}
 		} else {
 			log.out( 'No CKEditor5 plugins in development mode.' );