summaryrefslogtreecommitdiff
path: root/src/linit.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-02 15:01:54 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-03 13:28:11 +0200
commitd231ed14d0816eb26856e948a9ab72f64d46c1eb (patch)
tree4e85b5237878770195aedb362b6bd446f7f2596c /src/linit.js
parent5ac211f983cd628dfb95a6add7e5386071f4dada (diff)
downloadfengari-d231ed14d0816eb26856e948a9ab72f64d46c1eb.tar.gz
fengari-d231ed14d0816eb26856e948a9ab72f64d46c1eb.tar.bz2
fengari-d231ed14d0816eb26856e948a9ab72f64d46c1eb.zip
loadlib.js
Diffstat (limited to 'src/linit.js')
-rw-r--r--src/linit.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/linit.js b/src/linit.js
index 325dfa1..13e60e3 100644
--- a/src/linit.js
+++ b/src/linit.js
@@ -11,6 +11,7 @@ const lutf8lib = require('./lutf8lib.js');
const ldblib = require('./ldblib.js');
const liolib = require('./liolib.js');
const loslib = require('./loslib.js');
+const loadlib = require('./loadlib.js');
const lualib = require('./lualib.js');
const loadedlibs = {
@@ -25,6 +26,19 @@ const loadedlibs = {
"_G": lbaselib.luaopen_base
};
+// Only with Node
+if (typeof require === "function") {
+
+ let fs = false;
+ try {
+ fs = require('fs');
+ } catch (e) {}
+
+ if (fs) {
+ loadedlibs[lualib.LUA_LOADLIBNAME] = loadlib.luaopen_package;
+ }
+}
+
const luaL_openlibs = function(L) {
/* "require" functions from 'loadedlibs' and set results to global table */
for (let lib in loadedlibs) {