Closed
Description
This regards Node.js versions >= 4.0.0
Say I have a file with this content:
var foo = 'bar';
I want to read this file in, wrap it in a function and replace "bar" with "star"
something like this =>
Test.create(function(){
var foo = 'star';
});
so I can use a transform stream (replace stream to replace bar with star) like so:
fs.createReadStream(<file1>)
.pipe(new ReplaceStream('bar','star')).pipe(fs.createWriteStream(<file2>));
but my question is - what might be the recommended way to wrap the whole thing in a function? Is there a streamlined way that someone can think of do that?
Something like:
const writable = fs.createWriteStream(<file2>)
writable.write('Test.create(function(){');
fs.createReadStream(<file1>, {end:false})
.pipe(new ReplaceStream('bar','star')).pipe(writable, {end:false});
writable.end('})');
is that about right?
Metadata
Metadata
Assignees
Labels
No labels