Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 5, 2024
1 parent e3c4845 commit 9979bc2
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/helpers/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,17 @@ const fireTask = async ({
buffer,
// See `stream()` gulpfile
read,
// `execa` options
execaOpts,
}) => {
const execaOptsA = getExecaOpts({ command, opts, buffer, read, execaOpts })
// Some information is passed to the gulpfile using the environment variable
// `INPUT`, which is a JSON object.
const input = JSON.stringify({ command, opts, buffer, read })

const { exitCode, stdout, stderr } = await execa(
'gulp',
['--gulpfile', `${GULPFILES_DIR}/${method}.test.js`, task],
execaOptsA,
{ reject: false, env: { INPUT: input } },
)
const stdoutA = normalizeMessage(stdout)
const stderrA = normalizeMessage(stderr)
return { exitCode, stdout: stdoutA, stderr: stderrA }
}

const getExecaOpts = ({
command,
opts,
buffer,
read,
execaOpts: { env, ...execaOpts } = {},
}) => {
// Some information is passed to the gulpfile using the environment variable
// `INPUT`, which is a JSON object.
const input = JSON.stringify({ command, opts, buffer, read })

const execaEnv = { INPUT: input, ...env }
return { reject: false, env: execaEnv, ...execaOpts }
}

0 comments on commit 9979bc2

Please sign in to comment.