Skip to content

Transform the beginning of a stream/buffer, useful for adding runtimes

Notifications You must be signed in to change notification settings

kolodny/gulp-transform-head

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-transform-head

Transform the beginning of a stream/buffer, useful for adding runtimes


Usage:

.pipe(transformHead(delim, transformer, useBuffers))


delim: ( function |string | regex | number)

The thing to wait until true, if number: the amount of lines

transformer function

The function to transform the head of the file

useBuffer boolean (optional)

Force buffers in the delim and transformer functions

var transformHead = require('gulp-transform-head');

gulp.src('./foo/*.js')
  .pipe(transformHead(0, function(data) { return '"use scrict";\n' + data }))
  .pipe(gulp.dest('./dist/')

gulp.src('./bar/*.js')
  .pipe(transformHead(1, function(data) {
    if (/(['"])use scrict\1/.test(data.split('\n')[0])) {
      throw new gutil.PluginError('plugin', 'You need to use scrict mode');
    }
    return '"use scrict";\n' + data;
  }))
  .pipe(gulp.dest('./dist/')

gulp.src('./baz/*.js')
  .pipe(transformHead('(function(window', function(data) {
    return '(function main(window' + data;
  }))
  .pipe(gulp.dest('./dist/')

About

Transform the beginning of a stream/buffer, useful for adding runtimes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published