From 12f41c66c4513f756a1af60af5e65ccabcb15f55 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Wed, 15 May 2019 10:00:00 +0200 Subject: [PATCH] Simplify code --- src/stream.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/stream.js b/src/stream.js index 5498795..be93bd6 100644 --- a/src/stream.js +++ b/src/stream.js @@ -45,12 +45,14 @@ const forcedOpts = { stdio: undefined, } +// `save` should retrieve output as string, but this is not needed for +// `replace`. Same thing with final newline stripping. const addDefaultOpts = function({ opts, opts: { result } }) { - // `save` should retrieve output as string, but this is not needed for - // `replace`. Same thing with final newline stripping. - const replaceOpts = - result === 'replace' ? { encoding: 'buffer', stripFinalNewline: false } : {} - return { ...replaceOpts, ...opts } + if (result === 'save') { + return opts + } + + return { encoding: 'buffer', stripFinalNewline: false, ...opts } } const cExecVinyl = async function({ mapFunc, opts, resultOpt }, file) {