Skip to content

Instantly share code, notes, and snippets.

@miya0001
Last active April 24, 2016 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miya0001/082ab50040e52dda833271c923513e76 to your computer and use it in GitHub Desktop.
Save miya0001/082ab50040e52dda833271c923513e76 to your computer and use it in GitHub Desktop.
Example gulp plugin
var gutil = require( 'gulp-util' );
var through = require( 'through2' );
var path = require( 'path' );
module.exports = function () {
var transform = function( file, enc, callback ) {
var content = file.contents.toString();
// Do something to content here
var newfile = new gutil.File( {
cwd: __dirname,
path: path.join( __dirname, file.path ), // Do something if you need
contents: new Buffer( JSON.stringify( content ) + "\n" )
} );
this.push( newfile );
return callback();
};
return through.obj( transform );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment