Last active
April 24, 2016 18:03
-
-
Save miya0001/082ab50040e52dda833271c923513e76 to your computer and use it in GitHub Desktop.
Example gulp plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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