|
@@ -3,57 +3,28 @@
|
|
|
* For licensing, see LICENSE.md.
|
|
* For licensing, see LICENSE.md.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-'use strict';
|
|
|
|
|
|
|
+ 'use strict';
|
|
|
|
|
|
|
|
const gulp = require( 'gulp' );
|
|
const gulp = require( 'gulp' );
|
|
|
-const through = require( 'through2' );
|
|
|
|
|
const path = require( 'path' );
|
|
const path = require( 'path' );
|
|
|
-const filter = require( 'gulp-filter' );
|
|
|
|
|
-const gitignore = require( 'parse-gitignore' );
|
|
|
|
|
-const fs = require( 'fs' );
|
|
|
|
|
-const PassThrough = require( 'stream' ).PassThrough;
|
|
|
|
|
const replace = require( 'gulp-replace' );
|
|
const replace = require( 'gulp-replace' );
|
|
|
-
|
|
|
|
|
-function filterGitignore() {
|
|
|
|
|
- const fp = '.gitignore';
|
|
|
|
|
-
|
|
|
|
|
- if ( !fs.existsSync( fp ) ) {
|
|
|
|
|
- return new PassThrough( { objectMode: true } );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- let glob = gitignore( fp );
|
|
|
|
|
- let inverted = glob.map(
|
|
|
|
|
- pattern => pattern.startsWith( '!' ) ? pattern.slice( 1 ) : '!' + pattern
|
|
|
|
|
- );
|
|
|
|
|
- inverted.unshift( '**/*' );
|
|
|
|
|
-
|
|
|
|
|
- return filter( inverted );
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const gitignore = require( '../utils/gitignore-filter' );
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* {String} workdir
|
|
* {String} workdir
|
|
|
*/
|
|
*/
|
|
|
module.exports = ( workdir ) => {
|
|
module.exports = ( workdir ) => {
|
|
|
|
|
+ // Change to correct year
|
|
|
|
|
+ const year = '2017';
|
|
|
|
|
+ const licenseRegexp = /(@license Copyright \(c\) 2003-)[0-9]{4}/g;
|
|
|
const glob = path.join( 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 )
|
|
return gulp.src( glob )
|
|
|
- .pipe( filterGitignore() )
|
|
|
|
|
|
|
+ .pipe( gitignore() )
|
|
|
.pipe( replace(
|
|
.pipe( replace(
|
|
|
- reLicense,
|
|
|
|
|
- yearReplacement,
|
|
|
|
|
|
|
+ licenseRegexp,
|
|
|
|
|
+ `$1${ year }`,
|
|
|
{ skipBinary: true }
|
|
{ skipBinary: true }
|
|
|
) )
|
|
) )
|
|
|
- .pipe( through.obj( ( file, enc, next ) => {
|
|
|
|
|
- fileCount++;
|
|
|
|
|
-
|
|
|
|
|
- next( null, file );
|
|
|
|
|
- } ) )
|
|
|
|
|
- .pipe( gulp.dest( workdir ) )
|
|
|
|
|
- .on( 'end', ( ) => {
|
|
|
|
|
- console.log( 'File count:', fileCount );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ .pipe( gulp.dest( workdir ) );
|
|
|
};
|
|
};
|