summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/loslib.js6
-rw-r--r--tests/loslib.js2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/loslib.js b/src/loslib.js
index 745bbab..4d549b6 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -178,7 +178,11 @@ if (!WEB) {
syslib.getenv = function(L) {
let key = lauxlib.luaL_checkstring(L, 1);
key = lua.to_jsstring(key); /* https://github.com/nodejs/node/issues/16961 */
- lua.lua_pushliteral(L, process.env[key]); /* if NULL push nil */
+ if (Object.prototype.hasOwnProperty.call(process.env, key)) {
+ lua.lua_pushliteral(L, process.env[key]);
+ } else {
+ lua.lua_pushnil(L);
+ }
return 1;
};
diff --git a/tests/loslib.js b/tests/loslib.js
index 5f49043..2470359 100644
--- a/tests/loslib.js
+++ b/tests/loslib.js
@@ -2,6 +2,8 @@
const test = require('tape');
+global.WEB = false;
+
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');