mirror of https://gitee.com/bigwinds/arangodb
added autoload for modules
Conflicts: CHANGELOG js/server/js-server.h
This commit is contained in:
parent
4d6b3e1b5f
commit
7f33ac5519
|
@ -172,6 +172,10 @@ v1.1.beta1 (2012-XX-XX)
|
|||
as before. The Javascript API in the shell also offers a new update() method in extension to
|
||||
the previously existing replace() method.
|
||||
|
||||
v1.0.2 (2012-XX-XX)
|
||||
-------------------
|
||||
|
||||
* added autoload for modules
|
||||
|
||||
v1.0.1 (2012-09-30)
|
||||
-------------------
|
||||
|
|
|
@ -688,6 +688,14 @@ bool ApplicationV8::prepareV8Instance (size_t i) {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
v8::HandleScope scope;
|
||||
TRI_ExecuteJavaScriptString(context->_context,
|
||||
v8::String::New("require(\"internal\").actionLoaded()"),
|
||||
v8::String::New("action loaded"),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
// and return from the context
|
||||
|
|
|
@ -62,9 +62,38 @@
|
|||
internal.defineAction = function() {
|
||||
console.error("SYS_DEFINE_ACTION not available");
|
||||
};
|
||||
|
||||
internal.actionLoaded = function() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
internal.defineAction = SYS_DEFINE_ACTION;
|
||||
|
||||
internal.actionLoaded = function() {
|
||||
var modules;
|
||||
var i;
|
||||
|
||||
console.debug("actions loaded");
|
||||
|
||||
modules = internal.db._collection("_modules");
|
||||
|
||||
if (modules !== null) {
|
||||
modules = modules.byExample({ autoload: true }).toArray();
|
||||
|
||||
for (i = 0; i < modules.length; ++i) {
|
||||
var module = modules[i];
|
||||
|
||||
console.debug("autoloading module: %s", module.path);
|
||||
|
||||
try {
|
||||
require(module.path);
|
||||
}
|
||||
catch (err) {
|
||||
console.error("while loading '%s': %s", module.path, String(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION === "undefined") {
|
||||
|
|
Loading…
Reference in New Issue