Gulp extension to add a header to file(s) in the pipeline
Clone or download
Pull request Compare This branch is 116 commits ahead of douglasduteil:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.

gulp-header NPM version Build Status

gulp-header is a Gulp extension to add a header to file(s) in the pipeline. Gulp is a streaming build system utilizing node.js.


npm install --save-dev gulp-header


// assign the module to a local variable
var header = require('gulp-header');

// literal string
// NOTE: a line separator will not be added automatically

// ejs style templating
  .pipe(header('Hello <%= name %>\n', { name : 'World'} ))

// ES6-style template string
  .pipe(header('Hello ${name}\n', { name : 'World'} ))

// using data from package.json
var pkg = require('./package.json');
var banner = ['/**',
  ' * <%= %> - <%= pkg.description %>',
  ' * @version v<%= pkg.version %>',
  ' * @link <%= pkg.homepage %>',
  ' * @license <%= pkg.license %>',
  ' */',

  .pipe(header(banner, { pkg : pkg } ))

// reading the header file from disk
var fs = require('fs');
  .pipe(header(fs.readFileSync('header.txt', 'utf8'), { pkg : pkg } ))

// for use with coffee-script
return gulp.src([
    .pipe(header(banner, { pkg : pkg } ))
    .pipe(sourcemaps.init()) // init sourcemaps *after* header
        bare: true

Issues and Alerts

My handle on twitter is @tracker1 - If there is an urgent issue, I get twitter notifications sent to my phone.


header(text, data)


Type: String Default: ''

The template text.


Type: Object Default: {}

The data object used to populate the text.

In addition to the passed in data, file will be the stream object for the file being templated against and filename will be the path relative from the stream's basepath.

NOTE: using false will disable template processing of the header