JSPM

gulp-intercept

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4515
  • Score
    100M100P100Q107629F
  • License MIT

Intercept Gulp streams and take full control of the content.

Package Exports

  • gulp-intercept

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-intercept) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-intercept

Gulp plugin to intercept a Gulp stream.

The plugin accepts a function with a single argument - a chunk or file. Do whatever you need to eg. parse the file if its json, convert it if less or coffeescript or simply perform an update to its contents.

Usage

  • Install - npm install gulp-intercept --save-dev
  • Update your gulpfile.js:
var intercept = require('./gulp-intercept');
var concat = require('gulp-concat');

gulp.task('task', function () {
  gulp.src(['./*.txt'])
    .pipe(intercept(function(file){
      console.log('FILE: ' + file.path );
      console.log('OLD CONTENT: ' + file.contents.toString() );
      file.contents = new Buffer( "Hello!!!" );
      console.log('NEW CONTENT: ' + file.contents.toString() );
      return file;
    })) 
    .pipe(concat('onefile.txt'))
    .pipe(gulp.dest('./'));
});

API

intercept( method )

Type: Function method - Is a function that accepts a File and returns a File.

function ( file ) {
  // do stuff
  return file;
}