Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/tap.js

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

4 changes: 2 additions & 2 deletions lib/tap.js.map

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

8 changes: 6 additions & 2 deletions src/tap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ DEBUG = process.env.NODE_ENV is 'development'
# Taps into the pipeline and allows user to easily route data through
# another stream or change content.
###
module.exports = (lambda) ->
module.exports = () ->

lambda = arguments[0];
lambdaArgs = [].slice.call(arguments, 1);

utils = (tapStream, file) ->

###
Expand Down Expand Up @@ -41,7 +45,7 @@ module.exports = (lambda) ->

modifyFile = (file, enc, cb) ->
inst = file: file
obj = lambda(inst.file, utils(this, inst.file), inst)
obj = lambda.apply(null, [inst.file, utils(this, inst.file), inst].concat(lambdaArgs))

next = () =>
this.push(file)
Expand Down
36 changes: 36 additions & 0 deletions tests/args.test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
fs = require 'fs'
path = require 'path'
gulp = require 'gulp'
tap = require '../'
tapTest = require 'tap'

test2 = (file, a, b, test) ->
test.ok true

test3 = (file, a, b, test, value) ->
if value == "my value"
test.ok true
test.end()
else
test.ok false
test.end()

# helper function to get a path relative to the root
getPath = (rel) -> path.resolve __dirname, '..', rel

tapTest.test "works with passing 0, 1, n args to tap", (test) ->

test.plan 3

fixturePath = getPath 'tests/fixtures/'

gulp.src fixturePath + '/js.js'
.pipe tap (file) ->
test.ok true

gulp.src fixturePath + '/js.js'
.pipe tap test2, test

gulp.src fixturePath + '/js.js'
.pipe tap test3, test, "my value"