aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-08-17 15:38:28 +1000
committerdaurnimator <quae@daurnimator.com>2017-08-17 15:38:28 +1000
commit901a0c2b833fd99a36c21dea71a548d9d7df2be0 (patch)
treec752929285daad36440e1c294c811e9da08904f3 /src
parentd1214681a314f6ee50c2f02740f59bb9ce6902a3 (diff)
downloadfengari-901a0c2b833fd99a36c21dea71a548d9d7df2be0.tar.gz
fengari-901a0c2b833fd99a36c21dea71a548d9d7df2be0.tar.bz2
fengari-901a0c2b833fd99a36c21dea71a548d9d7df2be0.zip
src/loadlib.js: Use window as env in browser
Diffstat (limited to 'src')
-rw-r--r--src/loadlib.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index 641948f..e7cc7d3 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -171,15 +171,22 @@ const ll_loadlib = function(L) {
}
};
+let env;
+if (WEB) {
+ env = window;
+} else {
+ env = process.env;
+}
+
/*
** Set a path
*/
const setpath = function(L, fieldname, envname, dft) {
let nver = `${envname}${lua.LUA_VERSUFFIX}`;
lua.lua_pushstring(L, lua.to_luastring(nver));
- let path = process.env[nver]; /* use versioned name */
+ let path = env[nver]; /* use versioned name */
if (path === undefined) /* no environment variable? */
- path = process.env[envname]; /* try unversioned name */
+ path = env[envname]; /* try unversioned name */
if (path === undefined || noenv(L)) /* no environment variable? */
lua.lua_pushstring(L, lua.to_luastring(dft, true)); /* use default */
else {