Wondering what’s next for npm?Check out our public roadmap! »

    gulp-transform-head

    0.0.1 • Public • Published

    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/')
     
     

    Install

    npm i gulp-transform-head

    DownloadsWeekly Downloads

    3

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar