Skip to content

Gulp extension to add a footer to file(s) in the pipeline

License

Notifications You must be signed in to change notification settings

louisremi/gulp-footer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-footer NPM version Build Status

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

var footer = require('gulp-footer');

API

footer(text, data)

text

Type: String
Default: ''

The template text.

data

Type: Object
Default: {}

The data object used to populate the text.

footer(footerCb)

footerCb

Type: Function
Default: undefined

The function that will return the footer text. It receives one argument: the file object.

Usage

var footer = require('gulp-footer');

gulp.src('./foo/*.js')
  .pipe(footer('Hello'))
  .pipe(gulp.dest('./dist/')

gulp.src('./foo/*.js')
  .pipe(footer('Hello <%= name %>\n', { name : 'World'} ))
  .pipe(gulp.dest('./dist/')

gulp.src('./foo/*.js')
  .pipe(footer('Hello ${name}\n', { name : 'World'} ))
  .pipe(gulp.dest('./dist/')

gulp.src('./foo/*.js')
  .pipe(footer(function(file) {
    return 'Hello ' + file.path;
  })
  .pipe(gulp.dest('./dist/')


//
var pkg = require('./package.json');
var banner = ['/**',
  ' * <%= pkg.name %> - <%= pkg.description %>',
  ' * @version v<%= pkg.version %>',
  ' * @link <%= pkg.homepage %>',
  ' * @license <%= pkg.license %>',
  ' */',
  ''].join('\n');

//passing in the text
gulp.src('./foo/*.js')
  .pipe(footer(banner, { pkg : pkg } ))
  .pipe(gulp.dest('./dist/')

//reading from a file for the text
var bannerText = fs.readFileSync('banner.js');

/*********************************************/
//If you want the text from a file...
var fs = require('fs');
var banner = fs.readFileSync('banner.txt');

About

Gulp extension to add a footer to file(s) in the pipeline

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published