gulp-tap icon indicating copy to clipboard operation
gulp-tap copied to clipboard

update to allow passing args to tap

Open patrick-rodgers opened this issue 8 years ago • 3 comments

This update allows the passing of an argument variable through to the lambda method. The argument can be a single value, array, or object - it is naively passed to the lambda. This addresses issue #17.

function myFunc(file, t, n, arg) {
//    arg === { t: 1 }
}

// gulp pipe omitted ...
tap(myFunc, { t: 1 })

Updated to also allow this:

function myFunc(file, t, n, arg, arg2, arg3) {
//    arg === { t: 1 }
// arg2 === "foo"
// arg3 === "bar"
}

// gulp pipe omitted ...
tap(myFunc, { t: 1 }, "foo", "bar")

patrick-rodgers avatar Dec 08 '17 21:12 patrick-rodgers

@patrick-rodgers Thank you very much for your contribution. Will you please add two tests for this?

Bonus if you have a use-case you can link to so we can put it in the wiki and write about the motivation for this feature in the next release.

Thanks

dotnetCarpenter avatar Dec 16 '17 09:12 dotnetCarpenter

Added the tests to cover calling tap with 0, 1, or 2 args. As for a usecase you can have a look at where I used it in a task to build docs. I needed to grab the header and footer for each article and wanted to only get them once to pass them on to the function to create the html article.

patrick-rodgers avatar Jan 02 '18 15:01 patrick-rodgers

Oh, and all the tests pass, but please do have a look as CoffeeScript is new to me so always possible I am not actually calling anything :)

patrick-rodgers avatar Jan 02 '18 15:01 patrick-rodgers