summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/loadlib.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index e7cc7d3..acdf514 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -49,14 +49,12 @@ if (WEB) {
}
};
} else {
+ const pathlib = require('path');
lsys_load = function(L, path) {
+ path = lua.to_jsstring(path);
+ /* relative paths should be relative to cwd, not this js file */
+ path = pathlib.resolve(process.cwd(), path);
try {
- path = lua.to_jsstring(path);
-
- // Relative path ?
- if (path.startsWith('.'))
- path = `${process.env.PWD}/${path}`;
-
return require(path);
} catch (e) {
lua.lua_pushstring(L, lua.to_luastring(e.message));