Skip to content

Commit

Permalink
Improve gulp-execa
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 15, 2019
1 parent b833e21 commit a7d9808
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gulp/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const execa = require('execa')
const PluginError = require('plugin-error')

// Execute a shell command
// To create a Gulp task, one should not use `bind()` as it removes
// `Function.name`. Instead one should do `const taskName = () => exec(...)`
const exec = async function(command, opts = {}) {
const optsA = addStdio({ opts })

Expand All @@ -18,18 +20,16 @@ const exec = async function(command, opts = {}) {
// Default to piping shell stdin|stdout|stderr to console.
const addStdio = function({ opts }) {
// Unless user specified another stdio redirection.
const hasStdioOption = STDIO_OPTIONS.some(
stdioOption => opts[stdioOption] !== undefined,
)

if (hasStdioOption) {
if (opts.stdio !== undefined) {
return opts
}

return { ...opts, stdio: 'inherit' }
}
if (opts.input !== undefined) {
return { stdout: 'inherit', stderr: 'inherit', ...opts }
}

const STDIO_OPTIONS = ['stdio', 'stdin', 'stdout', 'stderr']
return { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit', ...opts }
}

// Retrieve error message to print
const getErrorMessage = function({
Expand Down

0 comments on commit a7d9808

Please sign in to comment.