summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-08-18 11:04:55 +1000
committerdaurnimator <quae@daurnimator.com>2017-08-18 11:04:55 +1000
commit389630abe2f44e122d29af7159dd1a0d5c585d15 (patch)
tree7825a6b89e1205fe9d12979fd48f6883c564f0b7 /src/loadlib.js
parent1007332a6854f66c0cbf60f477e064f615faaa74 (diff)
downloadfengari-389630abe2f44e122d29af7159dd1a0d5c585d15.tar.gz
fengari-389630abe2f44e122d29af7159dd1a0d5c585d15.tar.bz2
fengari-389630abe2f44e122d29af7159dd1a0d5c585d15.zip
src/loadlib.js: Use path.resolve to construct paths
Diffstat (limited to 'src/loadlib.js')
-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));