Comparing version 0.4.5 to 0.4.6
@@ -6,13 +6,13 @@ (function() { | ||
serverRequire = function(path) { | ||
var tryPath; | ||
tryPath = path; | ||
if (path[0] === ".") { | ||
path = process.cwd() + "/" + path; | ||
} else { | ||
path = process.cwd() + "/node_modules/" + path; | ||
tryPath = process.cwd() + "/" + path; | ||
} | ||
try { | ||
return require(path); | ||
return require(tryPath); | ||
} catch (e) { | ||
if (e.code === "MODULE_NOT_FOUND") { | ||
throw { | ||
message: "Censeo could not find the file '" + path + "'", | ||
message: "Censeo could not find the file '" + tryPath + "'", | ||
code: e.code | ||
@@ -91,3 +91,3 @@ }; | ||
socket.on("runTask", function(options) { | ||
var context, runFunc, gen4_asyncResult, result; | ||
var context, runFunc, result, gen4_asyncResult; | ||
return new Promise(function(gen2_onFulfilled) { | ||
@@ -100,9 +100,20 @@ context = options.context; | ||
runFunc = Function("context", "\n for (var property in context) {\n eval ('var '+property+'= context.'+property);\n }\n\n " + pogoWrappers() + "\n\n return (" + options.func + ")();\n "); | ||
gen2_onFulfilled(Promise.resolve(runFunc(context)).then(function(gen4_asyncResult) { | ||
result = gen4_asyncResult; | ||
tasks.push({ | ||
id: options.id, | ||
stop: result.stop | ||
}); | ||
return socket.emit("running:" + options.id, result); | ||
result = void 0; | ||
gen2_onFulfilled(new Promise(function(gen2_onFulfilled) { | ||
gen2_onFulfilled(Promise.resolve(runFunc(context)).then(function(gen5_asyncResult) { | ||
return result = gen5_asyncResult; | ||
})); | ||
}).then(void 0, function(e) { | ||
return console.log("Error starting task on server", e); | ||
}).then(function(gen4_asyncResult) { | ||
gen4_asyncResult; | ||
if (result) { | ||
tasks.push({ | ||
id: options.id, | ||
stop: result.stop | ||
}); | ||
return socket.emit("running:" + options.id, result); | ||
} else { | ||
return socket.emit("error:" + options.id); | ||
} | ||
})); | ||
@@ -125,14 +136,14 @@ }); | ||
runningTask = function() { | ||
var gen5_results, gen6_items, gen7_i, task; | ||
gen5_results = []; | ||
gen6_items = tasks; | ||
for (gen7_i = 0; gen7_i < gen6_items.length; ++gen7_i) { | ||
task = gen6_items[gen7_i]; | ||
var gen6_results, gen7_items, gen8_i, task; | ||
gen6_results = []; | ||
gen7_items = tasks; | ||
for (gen8_i = 0; gen8_i < gen7_items.length; ++gen8_i) { | ||
task = gen7_items[gen8_i]; | ||
(function(task) { | ||
if (task.id === options.id) { | ||
return gen5_results.push(task); | ||
return gen6_results.push(task); | ||
} | ||
})(task); | ||
} | ||
return gen5_results; | ||
return gen6_results; | ||
}()[0]; | ||
@@ -139,0 +150,0 @@ if (runningTask) { |
{ | ||
"name": "censeo", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Run arbitrary JavaScript or PogoScript on a server", | ||
@@ -5,0 +5,0 @@ "author": "Derek Ekins <derek@spathi.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
16918
255