Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 15, 2019
1 parent 596f428 commit 54996d0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import through from 'through2-concurrent'
import { isValidInput } from './input.js'
import { parseOpts } from './options.js'
import { execCommand, streamCommand } from './exec.js'
import { pickBy } from './utils.js'

// Creates a stream to use in Gulp e.g.
// src(...).pipe(stream(({ path }) => ['command', [path]]))
Expand Down Expand Up @@ -42,18 +41,16 @@ const forcedOpts = {
// - `overwrite|stream` mode would not work.
stdout: 'pipe',
stderr: 'pipe',
// `stdio` cannot be combined with `stdout|stderr` (`forcedOpts`) with execa
stdio: undefined,
}

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 } : {}

// `stdio` cannot be combined with `stdout|stderr` (`forcedOpts`) with execa
const optsA = pickBy(opts, (value, key) => key !== 'stdio')

return { ...replaceOpts, ...optsA }
return { ...replaceOpts, ...opts }
}

const cExecVinyl = async function({ mapFunc, opts, resultOpt }, file) {
Expand Down

0 comments on commit 54996d0

Please sign in to comment.