Perform extension test once

This does not need to be computed on each path since
file isn't changing between paths visited
This commit is contained in:
Kevin Sawicki
2013-01-18 09:14:14 -08:00
parent a7f03f4aeb
commit 43d0c8a2a1

View File

@@ -82,9 +82,10 @@ resolve = (name, {verifyExistence}={}) ->
file = expanded
if not moduleAlreadyLoaded
hasExtension = /\.(.+)$/.test(file)
paths.some (path) ->
fileExists = /\.(.+)$/.test(file) and __exists "#{path}/#{file}"
jsFileExists = not /\.(.+)$/.test(file) and __exists "#{path}/#{file}.js"
fileExists = hasExtension and __exists "#{path}/#{file}"
jsFileExists = not hasExtension and __exists "#{path}/#{file}.js"
if jsFileExists
file = "#{path}/#{file}.js"