diff --git a/Rakefile b/Rakefile index f0ebc9a55..141b722b0 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ task :build do dest = File.join(built_dir, contents_dir, "Resources") - %w(index.html src docs static extensions vendor ).each do |dir| + %w(index.html src docs static extensions vendor spec).each do |dir| rm_rf File.join(dest, dir) cp_r dir, File.join(dest, dir) end @@ -19,7 +19,7 @@ task :build do "http://coffeescript.org/ - (try `npm i -g coffee-script`)" end - sh "coffee -c #{dest}/src/stdlib/require.coffee" + sh "coffee -c #{dest}/src #{dest}/vendor #{dest}/extensions #{dest}/spec" end desc "Install the app in /Applications" diff --git a/src/stdlib/require.coffee b/src/stdlib/require.coffee index 9096daf98..d05474601 100644 --- a/src/stdlib/require.coffee +++ b/src/stdlib/require.coffee @@ -79,8 +79,13 @@ resolve = (file) -> if file[0] isnt '/' require.paths.some (path) -> - if /\.(.+)$/.test(file) and __exists "#{path}/#{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 expanded = __expand "#{path}/#{file}" file = expanded else