Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Support for setting a root for requires. Useful if you're doing many …

…requires in the same directory.
  • Loading branch information...
commit 721357d572cfd02f135638c9c78a215077faeab2 1 parent 060dcc9
Peter Wagenet authored November 18, 2011

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. 11  lib/main.js
11  lib/main.js
... ...
@@ -1,6 +1,7 @@
1 1
 if (typeof document !== "undefined") {
2 2
   (function() {
3 3
     minispade = {
  4
+      root: null,
4 5
       modules: {},
5 6
       loaded: {},
6 7
 
@@ -10,10 +11,14 @@ if (typeof document !== "undefined") {
10 11
 
11 12
         if (!loaded) {
12 13
           if (mod) {
13  
-            loaded = mod();
  14
+            loaded = mod() || true;
14 15
             minispade.loaded[name] = loaded;
15 16
           } else {
16  
-            throw "The module '" + name + "' could not be found";
  17
+            if (minispade.root && name.substr(0,minispade.root.length) !== minispade.root) {
  18
+              return minispade.require(minispade.root+name);
  19
+            } else {
  20
+              throw "The module '" + name + "' could not be found";
  21
+            }
17 22
           }
18 23
         }
19 24
 
@@ -35,4 +40,4 @@ if (typeof document !== "undefined") {
35 40
       }
36 41
     });
37 42
   })();
38  
-}
  43
+}

0 notes on commit 721357d

Please sign in to comment.
Something went wrong with that request. Please try again.