From bdb0d2c709e82e787238d938c3daaed436e04d02 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 26 Oct 2012 15:28:12 -0700 Subject: [PATCH] Log a warning when require.resolve cannot find the file --- src/stdlib/require.coffee | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/stdlib/require.coffee b/src/stdlib/require.coffee index 886836428..c6c2ee96f 100644 --- a/src/stdlib/require.coffee +++ b/src/stdlib/require.coffee @@ -57,7 +57,9 @@ exts = coffee: (file) -> exts.js(file, __coffeeCache(file)) -resolve = (file) -> +resolve = (name, {verifyExistence}={}) -> + verifyExistence ?= true + file = name if /!/.test file parts = file.split '!' file = parts[parts.length-1] @@ -75,18 +77,19 @@ resolve = (file) -> fileExists = /\.(.+)$/.test(file) and __exists "#{path}/#{file}" jsFileExists = not /\.(.+)$/.test(file) and __exists "#{path}/#{file}.js" - if fileExists - file = "#{path}/#{file}" if jsFileExists file = "#{path}/#{file}.js" + else if fileExists + file = "#{path}/#{file}" else if expanded = __expand "#{path}/#{file}" file = expanded else file = __expand(file) or file - if file[0] == '/' + if file[0] == '/' and (not verifyExistence or __exists(file)) file else + console.warn("Failed to resolve '#{name}'") null __expand = (path) ->