diff --git a/oxygen/js-require/commons.js b/oxygen/js-require/commons.js index 31a4b6b..bd0c436 100644 --- a/oxygen/js-require/commons.js +++ b/oxygen/js-require/commons.js @@ -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(); } -} +} \ No newline at end of file