Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including gulp-header with all npm packages installed. Try it out:

var gulpHeader = require("gulp-header")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-header v2.0.9

Gulp extension to add header to file(s) in the pipeline.

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


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free