Implemeting both require and include.
This commit is contained in:
parent
b62623370a
commit
5203bbf0e9
|
@ -11,12 +11,25 @@
|
|||
out = Packages.java.lang.System.out;
|
||||
CommonsOperationsUtil = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil;
|
||||
|
||||
/*
|
||||
* Function include
|
||||
*
|
||||
*/
|
||||
include = function (filepath) {
|
||||
out.println('include("' + filepath + '")');
|
||||
filepath = CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
|
||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
|
||||
text = String(text);
|
||||
eval(text);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function require
|
||||
*
|
||||
*/
|
||||
require = function (filepath) {
|
||||
out.println('require("' + filepath + '")');
|
||||
|
||||
// Check if the object has been initialized
|
||||
if (Object.keys(require).length == 0) {
|
||||
|
@ -34,11 +47,7 @@ require = function (filepath) {
|
|||
if (require.urisSet[filepath] == undefined) {
|
||||
require.urisStack.push(filepath);
|
||||
require.urisSet[filepath] = true;
|
||||
var uri = new java.net.URI(filepath);
|
||||
out.println('Including ' + uri.toString());
|
||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (targetURI)));
|
||||
text = String(text);
|
||||
eval(text);
|
||||
include(filepath);
|
||||
require.urisStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue