Skip to content
Browse files

issue #2 fixed

  • Loading branch information...
1 parent 99ef6ca commit cbfa00dd7cea38c73525dcb616cefe984a9c719a @matthewfl matthewfl committed Dec 3, 2010
Showing with 8 additions and 6 deletions.
  1. +3 −2 sandbox/boxed.js
  2. +3 −3 sandbox/build.js
  3. +2 −1 sandbox/modules.js
View
5 sandbox/boxed.js
@@ -20,9 +20,10 @@ __filename="main.js";
var fn = eval("(function (exports, __server, __loop_check_, require, __get_code, __process_compile, __process_exit, debug) {\n " + code + " \n return exports;\n})");
modules[name]=(function () { return {} })();
return fn.apply(modules[name], [modules[name], __server, loop_check, global.require, __get_code, __process_compile, __process_exit, debug]);
- //if(modules[name].fail) throw name + " is not to be required in";
return modules[name];
- }else {
+ }else if(typeof code == "undefined") {
+ throw "module "+name+" was not found";
+ }else{
return modules[name] = code;
}
};
View
6 sandbox/build.js
@@ -6,7 +6,7 @@ exports.build = function (code, user, back) {
var ret={};
var need={};
ret._=jsmin("", code, 1);
- code.replace(/require\s*?\((.*)\)/g, function (r, v) {
+ code.replace(/require\s*?\((.*?)\)/g, function (r, v) {
try {
console.log(v);
need[v.replace(/\"(.*)\"|\'(.*)\'/, function (r) { return r.substring(1,r.length-1); })]=true;
@@ -22,11 +22,11 @@ exports.build = function (code, user, back) {
count++;
(function (name) {
db.get("fs_"+user+"_"+name.substring(2), function (code) {
- ret[name] = code || "throw 'not found';";
+ ret[name] = code ? jsmin("",code,1) : "throw 'not found';";
if(!--count) back(ret);
});
})(name);
- }else if(modules[name]) {}
+ }else if(typeof modules[name] != "undefined") {}
else if(name.indexOf('/')) {
// will be used latter
}else
View
3 sandbox/modules.js
@@ -58,6 +58,7 @@ exports.db = exports.database = function (context, config) {
db = db || require('../db');
var baseName = "db_"+config.user+"_"+config.name+"_";
var tmp={};
+ console.log(config);
return {
get: function (name, back) {
if(config.test && tmp[name]) back(tmp[name]);
@@ -94,7 +95,7 @@ exports.fs = function (context, config) {
throw "The filesystem supports no modifications of the file system from the application";
}
function noSync () {
- throw "The file system supports not synchronous calls";
+ throw "The file system does not supports synchronous calls";
}
return {
unlink: noMod,

0 comments on commit cbfa00d

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