check an array of search paths to find a file
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
testdata
.jshintrc
.travis.yml
README.md
index.js
package.json
test.js

README.md

Build Status

trail

trail checks for a file or directory on a bunch of search paths. for example, given the paths ['a', 'b', 'c'] and the basename 'file' it'll return the first of ['a/file', 'b/file', 'c/file'] that exists.

trail(paths, basename, cb)

paths should be an array, basename should be a string. cb should be a callback that takes error and pathname arguments. No error is ever passed. If the file is not found, null is passed as pathname.

trail.bail(paths, basename, cb)

Like trail, but passes 'not found' as error when it can't find the file. Very useful with async's waterfall.