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 400,000 packages pre-installed, including bannerize with all npm packages installed. Try it out:

var bannerize = require("bannerize")

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

bannerize v1.1.2

Add a dynamic banner/license comment to any text file.

Bannerize Build Status

Add dynamic banner/license comments to files in a build process.

$ npm install -g bannerize

Banner Templates

Banner templates use the EJS templating language. Templates are passed the following properties:

  • pkg: A representation of the nearest package.json file.
  • date: A JavaScript Date object.

A simple banner might look something like:

/*! <%= pkg.name %> | <%= pkg.version %>
 *  (c) <%= date.getFullYear() %> <%= pkg.license %>
 */

And render to:

/*! bannerize | 1.0.0
 *  (c) 2015 MIT
 */

CLI

bannerize ships with a CLI command. Its options vary from the programmatic API. To see all its options, use:

$ bannerize --help

An example usage might look like:

$ bannerize *.js *.css --banner=foo/bar.ejs

API

The bannerize module can be used in your programs. It exports a single function, bannerize, which takes two arguments:

bannerize(patterns, [options])

  • pattern {String|Array}: A string or array of glob pattern(s) to which to apply the banner.
  • [options] {Object}: An object containing optional values.

Options

  • banner A banner file location. Defaults to banner.ejs in the cwd.
  • cwd Override the cwd for all paths passed to bannerize. Relative paths will be relative to process.cwd(). Defaults to process.cwd().
  • lineBreak Sets the linebreak ('CRLF', 'LF'). Defaults to 'LF'.
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