Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function cleanContent() {
function transform(file, cb) {
file.contents = new Buffer((function (src) {
var lines = src.replace('_.mixin({\n','').split('\n'),
last = lines.pop();
// handle empty lines at the end of the file
while(last===''){
last = lines.pop();
}
return lines.join('\n');
})(String(file.contents)));
cb(null, file);
}
return require('event-stream').map(transform);
}
function getTransformer( func, clbk ) {
if ( !arguments.length ) {
throw new Error( 'getTransformer()::insufficient input arguments. Must provide a transformation function.' );
}
var stream = eventStream.map( function onData( data, callback ) {
callback( null, func( data ) );
});
stream.on( 'error', function onError( error ) {
if ( clbk ) {
clbk( error );
return;
}
console.error( error.stack );
});
return stream;
} // end FUNCTION getTransformer()
var compileTemplate = function() {
var transform = function(file, cb) {
var name = file.relative.replace(/\.html$/, '');
var contents = file.contents.toString()
.replace(/\"/g, '\\"')
.replace(/\n/g, '');
var content = 'templates["'+name+'"] = "'+contents+'";';
file.contents = new Buffer(String(content));
cb(null, file);
};
return eventStream.map(transform);
};
function translate() {
function transform(file, callback) {
file.contents = new Buffer(file.contents.toString().replace('[$Yo$]', 'yo dawg'));
callback(null, file);
}
return eventStream.map(transform);
}
module.exports = function(path, opt) {
if (!opt) opt = {};
var file = {
base: dirname(path),
path: path
};
file.shortened = realBase(file.base, file.path);
var stream = es.map(readFile);
process.nextTick(function(){
stream.write(file);
stream.end();
});
return stream;
};