Mathias Panzenböck avatar Mathias Panzenböck committed 193488b

run tests as main

Comments (0)

Files changed (1)

 		};
 	}
 
-	function make_require (parent, getters) {
+	function make_require (parent, main, getters) {
 		function _require (moduleName, opts) {
 			return __require(moduleName, opts, parent);
 		}
 			opts.async = false;
 		}
 
+		if (opts.asmain === undefined) {
+			opts.asmain = false;
+		}
+
 		var exports = loaded[resolver.id];
 	
 		if (exports === undefined) {
 			var globals = {
 				exports: exports,
 				include: include,
-				require: make_require(newModule),
-				module:  newModule,
+				require: null,
+				module:  null,
 			};
 	
 			if (opts.globals) {
 					}
 					else {
 						loading[resolver.id] = exports;
-						globals.module = newModule = new ModuleInfo(
+						newModule = new ModuleInfo(
 							resolver.id,
 							resolver.uri,
 							resolver.path,
 							parent);
-						globals.require = make_require(newModule);
 						xhr.open('GET', resolver.path, opts.async);
 						xhr.send(null);
 					}
 				}
 	
 				try {
+					globals.module  = newModule;
+					globals.require = make_require(newModule, opts.asmain ? newModule : main);
 					var program = _eval(
 						'(function (globals) { with (globals) { ' +
 						xhr.responseText+' }})');
 		return exports;
 	}
 	
-	return make_require(main, {
+	return make_require(main, main, {
 		clear: function () {
 			return function () {
 				var exports = loaded[main.id];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.