use Array.prototype.some where corey wanted to use _.detect

This commit is contained in:
Chris Wanstrath 2011-08-28 16:21:45 -07:00
parent f2e7d55a22
commit c57a8d8112

View File

@ -59,16 +59,11 @@ resolve = (file) ->
throw "require: ../ prefix not yet implemented"
if file[0] isnt '/'
# I want to use _.detect, but we don't have that at this point
# or break would do, but coffeescript doesn't have that
expandedPath = null
paths.forEach (path) ->
paths.some (path) ->
if /\.(.+)$/.test(file) and __exists "#{path}/#{file}"
expandedPath ?= "#{path}/#{file}"
else
expandedPath ?= expandPath("#{path}/#{file}")
file = expandedPath if expandedPath?
file = "#{path}/#{file}"
else if expanded = expandPath "#{path}/#{file}"
file = expanded
else
file = expandPath(file) or file