Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 15, 2019
1 parent 54996d0 commit 12f41c6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 12f41c6

Please sign in to comment.