Skip to content

Commit

Permalink
Improve task()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 10, 2019
1 parent 4dd902d commit 6c1ac19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"fancy-log": "^1.3.3",
"is-ci": "^2.0.0",
"plugin-error": "^1.0.1",
"rename-fn": "^1.0.0",
"through2-concurrent": "^2.0.0"
},
"devDependencies": {
Expand Down
17 changes: 8 additions & 9 deletions src/task.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import renameFn from 'rename-fn'

import { execBind } from './exec.js'

// Create a Gulp task
export const task = function(input, opts) {
const gulpTask = execBind(input, opts)
const gulpTask = execBind(input, { ...opts, ...FORCED_OPTS })

// We want to allow users to do `const gulpTask = execa(...)` instead of the
// more verbose `const gulpTask = () => execa(...)`. This is especially
// important when using `gulp.series()` or `gulp.parallel()`.
// However after binding a function or using a closure, assigning it to
// a variable does not change its `function.name` anymore. But this is
// used by Gulp as the displayed task name. So we use the command instead.
// eslint-disable-next-line fp/no-mutation
gulpTask.displayName = input
// Log the command and arguments as the inner function name
renameFn(gulpTask, input)

return gulpTask
}

// The `echo` option is not needed since the function name shows it already
const FORCED_OPTS = { echo: false }

0 comments on commit 6c1ac19

Please sign in to comment.