1- /* jshint node: true */
2- 'use strict' ;
3-
41/**
52 * Module dependencies.
63 */
74
8- var Concat = require ( 'concat-with-sourcemaps' ) ;
9- var through = require ( 'through2' ) ;
10- var lodashTemplate = require ( 'lodash.template' ) ;
11- var stream = require ( 'stream' ) ;
12- var path = require ( 'path' ) ;
13- var fs = require ( 'fs' ) ;
5+ const Concat = require ( 'concat-with-sourcemaps' ) ;
6+ const through = require ( 'through2' ) ;
7+ const lodashTemplate = require ( 'lodash.template' ) ;
8+ const stream = require ( 'stream' ) ;
9+ const path = require ( 'path' ) ;
1410
1511/**
1612 * gulp-header plugin
1713 */
1814
19- module . exports = function ( headerText , data ) {
15+ module . exports = ( headerText , data ) => {
2016 headerText = headerText || '' ;
2117
2218 function TransformStream ( file , enc , cb ) {
2319 // format template
24- var filename = path . basename ( file . path ) ;
25- var template =
26- data === false
27- ? headerText
20+ const filename = path . basename ( file . path ) ;
21+ const template =
22+ data === false ?
23+ headerText
2824 : lodashTemplate ( headerText ) (
2925 Object . assign ( { } , file . data || { } , { file : file , filename : filename } , data )
3026 ) ;
@@ -42,7 +38,7 @@ module.exports = function(headerText, data) {
4238
4339 // handle file stream;
4440 if ( file . isStream ( ) ) {
45- var stream = through ( ) ;
41+ const stream = through ( ) ;
4642 stream . write ( Buffer . from ( template ) ) ;
4743 stream . on ( 'error' , this . emit . bind ( this , 'error' ) ) ;
4844 file . contents = file . contents . pipe ( stream ) ;
@@ -51,7 +47,7 @@ module.exports = function(headerText, data) {
5147 }
5248
5349 // variables to handle direct file content manipulation
54- var concat = new Concat ( true , filename ) ;
50+ const concat = new Concat ( true , filename ) ;
5551
5652 // add template
5753 concat . add ( null , Buffer . from ( template ) ) ;
@@ -82,14 +78,14 @@ module.exports = function(headerText, data) {
8278/**
8379 * is stream?
8480 */
85- function isStream ( obj ) {
81+ const isStream = ( obj ) => {
8682 return obj instanceof stream . Stream ;
87- }
83+ } ;
8884
8985/**
9086 * Is File, and Exists
9187 */
92- function isExistingFile ( file ) {
88+ const isExistingFile = ( file ) => {
9389 try {
9490 if ( ! ( file && typeof file === 'object' ) ) return false ;
9591 if ( file . isDirectory ( ) ) return false ;
@@ -98,4 +94,4 @@ function isExistingFile(file) {
9894 if ( typeof file . contents === 'string' ) return true ;
9995 } catch ( err ) { }
10096 return false ;
101- }
97+ } ;
0 commit comments