From 901a0c2b833fd99a36c21dea71a548d9d7df2be0 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 17 Aug 2017 15:38:28 +1000 Subject: src/loadlib.js: Use window as env in browser --- src/loadlib.js | 11 +++++++++-- 1 file 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 { -- cgit v1.2.3-70-g09d2