From 488697884f0aef831bd738f11dfb4a29b6dc830c Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sat, 27 Aug 2011 14:26:52 -0700 Subject: [PATCH] add support for index.js to require() --- src/bootstrap.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bootstrap.coffee b/src/bootstrap.coffee index d525c1ddb..fd49feeca 100644 --- a/src/bootstrap.coffee +++ b/src/bootstrap.coffee @@ -4,6 +4,9 @@ console.log = (thing) -> OSX.NSLog thing.toString() modules = {} paths = ['src', 'vendor'] +read = (path) -> + root = OSX.NSBundle.mainBundle.resourcePath + OSX.NSString.stringWithContentsOfFile "#{root}/#{path}" this.require = (file) -> # hack for stupid requirejs if file.indexOf('ace/requirejs/text!') > -1 @@ -15,9 +18,10 @@ this.require = (file) -> code = null paths.forEach (path) -> return code if code - root = OSX.NSBundle.mainBundle.resourcePath + "/#{path}" - fullpath = if text then "#{root}/#{file}" else "#{root}/#{file}.js" - code = OSX.NSString.stringWithContentsOfFile fullpath + if text + code = read "#{path}/#{file}" + else + code = read("#{path}/#{file}.js") or read("#{path}/#{file}/index.js") if text modules[file] = code.toString()