From 23a8f4116d6c0c9df2668e1cd06fce13666549ad Mon Sep 17 00:00:00 2001 From: Elliot Nelson Date: Sat, 27 Oct 2018 10:14:35 -0400 Subject: [PATCH] Ensure the original file content is not replaced --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d1ec474..98bcd0f 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,12 @@ const through = require('through2') module.exports = function (fn) { return through.obj(function (file, enc, cb) { const contents = fn(String(file.contents), file.path, file) || file.contents + const modifiedFile = file.clone() if (file.isBuffer() === true) { - file.contents = new Buffer(contents) + modifiedFile.contents = new Buffer(contents) } - cb(null, file) + cb(null, modifiedFile) }) -} \ No newline at end of file +}