summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/defs.js2
-rw-r--r--src/lauxlib.js6
-rw-r--r--src/lbaselib.js2
-rw-r--r--src/ldblib.js3
-rw-r--r--src/linit.js2
-rw-r--r--src/loadlib.js8
-rw-r--r--src/loslib.js2
-rw-r--r--src/lualib.js2
-rw-r--r--tests/defs.js1
-rw-r--r--tests/lauxlib.js2
-rw-r--r--tests/loslib.js2
-rwxr-xr-xtests/manual-tests/debug-cli.js2
-rw-r--r--tests/test-suite/api.js2
-rw-r--r--tests/test-suite/attrib.js2
-rw-r--r--tests/test-suite/bitwise.js2
-rw-r--r--tests/test-suite/calls.js2
-rw-r--r--tests/test-suite/closure.js2
-rw-r--r--tests/test-suite/code.js2
-rw-r--r--tests/test-suite/constructs.js2
-rw-r--r--tests/test-suite/coroutine.js2
-rw-r--r--tests/test-suite/db.js2
-rw-r--r--tests/test-suite/errors.js2
-rw-r--r--tests/test-suite/events.js2
-rw-r--r--tests/test-suite/goto.js2
-rw-r--r--tests/test-suite/literals.js2
-rw-r--r--tests/test-suite/locals.js2
-rw-r--r--tests/test-suite/ltests.js2
-rw-r--r--tests/test-suite/math.js2
-rw-r--r--tests/test-suite/nextvar.js2
-rw-r--r--tests/test-suite/pm.js2
-rw-r--r--tests/test-suite/sort.js2
-rw-r--r--tests/test-suite/strings.js2
-rw-r--r--tests/test-suite/tpack.js2
-rw-r--r--tests/test-suite/utf8.js2
-rw-r--r--tests/test-suite/vararg.js2
-rw-r--r--tests/tests.js2
-rw-r--r--webpack.config.js2
37 files changed, 13 insertions, 71 deletions
diff --git a/src/defs.js b/src/defs.js
index 3ebb747..268e76e 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -291,7 +291,7 @@ module.exports.LUA_EXEC_DIR = LUA_EXEC_DIR;
const LUA_VDIR = LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR;
module.exports.LUA_VDIR = LUA_VDIR;
-if (WEB) {
+if (typeof process === "undefined") {
const LUA_DIRSEP = "/";
module.exports.LUA_DIRSEP = LUA_DIRSEP;
diff --git a/src/lauxlib.js b/src/lauxlib.js
index d976cee..f95f9a8 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -708,13 +708,13 @@ class LoadF {
constructor() {
this.n = NaN; /* number of pre-read characters */
this.f = null; /* file being read */
- this.buff = WEB ? new Array(1024) : new Buffer(1024); /* area for reading file */
+ this.buff = typeof process === "undefined" ? new Array(1024) : new Buffer(1024); /* area for reading file */
this.pos = 0; /* current position in file */
this.err = void 0;
}
}
-if (WEB) {
+if (typeof process === "undefined") {
const getF = function(L, ud) {
let lf = ud;
@@ -858,7 +858,7 @@ const luaL_dofile = function(L, filename) {
const lua_writestringerror = function() {
for (let i=0; i<arguments.length; i++) {
let a = arguments[i];
- if (WEB) {
+ if (typeof process === "undefined") {
if (typeof a !== "string")
a = lua.to_jsstring(a);
console.error(a);
diff --git a/src/lbaselib.js b/src/lbaselib.js
index c598474..874a868 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -5,7 +5,7 @@ const lauxlib = require('./lauxlib.js');
let lua_writestring;
let lua_writeline;
-if (WEB) {
+if (typeof process === "undefined") {
let buff = [];
lua_writestring = function(s) {
buff = buff.concat(s);
diff --git a/src/ldblib.js b/src/ldblib.js
index 2faa9f0..5912b5a 100644
--- a/src/ldblib.js
+++ b/src/ldblib.js
@@ -395,8 +395,7 @@ const dblib = {
"upvaluejoin": db_upvaluejoin
};
-// Only with Node
-if (!WEB) {
+if (typeof process !== "undefined") { // Only with Node
const readlineSync = require('readline-sync');
readlineSync.setDefaultOptions({
prompt: 'lua_debug> '
diff --git a/src/linit.js b/src/linit.js
index 90ad978..97cbfc9 100644
--- a/src/linit.js
+++ b/src/linit.js
@@ -26,7 +26,7 @@ const luaL_openlibs = function(L) {
"_G": lbaselib.luaopen_base
};
- if (!WEB) loadedlibs[lualib.LUA_IOLIBNAME] = require('./liolib.js').luaopen_io;
+ if (typeof process !== "undefined") loadedlibs[lualib.LUA_IOLIBNAME] = require('./liolib.js').luaopen_io;
/* "require" functions from 'loadedlibs' and set results to global table */
for (let lib in loadedlibs) {
diff --git a/src/loadlib.js b/src/loadlib.js
index dbd5c3c..ef39f4f 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -36,7 +36,7 @@ const AUXMARK = [1];
** error string in the stack.
*/
let lsys_load;
-if (WEB) {
+if (typeof process === "undefined") {
lsys_load = function(L, path, seeglb) {
path = lua.to_uristring(path);
let xhr = new XMLHttpRequest();
@@ -111,9 +111,7 @@ const noenv = function(L) {
};
let readable;
-// Only with Node
-if (!WEB) {
-
+if (typeof process !== "undefined") { // Only with Node
const fs = require('fs');
readable = function(filename) {
@@ -189,7 +187,7 @@ const ll_loadlib = function(L) {
};
let env;
-if (WEB) {
+if (typeof process === "undefined") {
env = window;
} else {
env = process.env;
diff --git a/src/loslib.js b/src/loslib.js
index 4b147cf..16df4ea 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -157,7 +157,7 @@ const syslib = {
"time": os_time
};
-if (WEB) {
+if (typeof process === "undefined") {
syslib.clock = function(L) {
lua.lua_pushnumber(L, performance.now()/1000);
return 1;
diff --git a/src/lualib.js b/src/lualib.js
index 50ca433..4fbae44 100644
--- a/src/lualib.js
+++ b/src/lualib.js
@@ -14,7 +14,7 @@ const LUA_TABLIBNAME = "table";
module.exports.LUA_TABLIBNAME = LUA_TABLIBNAME;
module.exports.luaopen_table = require("./ltablib.js").luaopen_table;
-if (!WEB) {
+if (typeof process !== "undefined") {
const LUA_IOLIBNAME = "io";
module.exports.LUA_IOLIBNAME = LUA_IOLIBNAME;
module.exports.luaopen_io = require("./liolib.js").luaopen_io;
diff --git a/tests/defs.js b/tests/defs.js
index 244e31b..9fd7f3b 100644
--- a/tests/defs.js
+++ b/tests/defs.js
@@ -1,6 +1,5 @@
const test = require('tape');
-global.WEB = false;
const defs = require('../src/defs.js');
const unicode_tests = [
diff --git a/tests/lauxlib.js b/tests/lauxlib.js
index 4e37296..d484edb 100644
--- a/tests/lauxlib.js
+++ b/tests/lauxlib.js
@@ -2,8 +2,6 @@
const test = require('tape');
-global.WEB = false;
-
const lua = require('../src/lua.js');
const lauxlib = require("../src/lauxlib.js");
diff --git a/tests/loslib.js b/tests/loslib.js
index 2470359..5f49043 100644
--- a/tests/loslib.js
+++ b/tests/loslib.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/manual-tests/debug-cli.js b/tests/manual-tests/debug-cli.js
index 5fba8e5..3feb981 100755
--- a/tests/manual-tests/debug-cli.js
+++ b/tests/manual-tests/debug-cli.js
@@ -1,8 +1,6 @@
#!/usr/bin/env node
"use strict";
-global.WEB = false;
-
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
diff --git a/tests/test-suite/api.js b/tests/test-suite/api.js
index 8b59e9c..b5f45c3 100644
--- a/tests/test-suite/api.js
+++ b/tests/test-suite/api.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/attrib.js b/tests/test-suite/attrib.js
index d6c3803..fcd3271 100644
--- a/tests/test-suite/attrib.js
+++ b/tests/test-suite/attrib.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/bitwise.js b/tests/test-suite/bitwise.js
index 3969bb0..df57f15 100644
--- a/tests/test-suite/bitwise.js
+++ b/tests/test-suite/bitwise.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/calls.js b/tests/test-suite/calls.js
index 451f6c0..fdd5eac 100644
--- a/tests/test-suite/calls.js
+++ b/tests/test-suite/calls.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/closure.js b/tests/test-suite/closure.js
index 8e9e4b1..464a5b5 100644
--- a/tests/test-suite/closure.js
+++ b/tests/test-suite/closure.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/code.js b/tests/test-suite/code.js
index 4438cd2..26ca021 100644
--- a/tests/test-suite/code.js
+++ b/tests/test-suite/code.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/constructs.js b/tests/test-suite/constructs.js
index 20a1210..f180195 100644
--- a/tests/test-suite/constructs.js
+++ b/tests/test-suite/constructs.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/coroutine.js b/tests/test-suite/coroutine.js
index 82f10a3..b85f0de 100644
--- a/tests/test-suite/coroutine.js
+++ b/tests/test-suite/coroutine.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/db.js b/tests/test-suite/db.js
index dcb57da..6d85a5f 100644
--- a/tests/test-suite/db.js
+++ b/tests/test-suite/db.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/errors.js b/tests/test-suite/errors.js
index 5980724..a6bc351 100644
--- a/tests/test-suite/errors.js
+++ b/tests/test-suite/errors.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/events.js b/tests/test-suite/events.js
index 0f94f36..9a15e93 100644
--- a/tests/test-suite/events.js
+++ b/tests/test-suite/events.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/goto.js b/tests/test-suite/goto.js
index c07541e..5acf633 100644
--- a/tests/test-suite/goto.js
+++ b/tests/test-suite/goto.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/literals.js b/tests/test-suite/literals.js
index d18d557..0078cf8 100644
--- a/tests/test-suite/literals.js
+++ b/tests/test-suite/literals.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/locals.js b/tests/test-suite/locals.js
index 3815f5d..cc82e38 100644
--- a/tests/test-suite/locals.js
+++ b/tests/test-suite/locals.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 2f48287..67ab87d 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -1,7 +1,5 @@
"use strict";
-global.WEB = false;
-
const assert = require("assert");
const lua = require('../../src/lua.js');
diff --git a/tests/test-suite/math.js b/tests/test-suite/math.js
index ea021d2..0052bc2 100644
--- a/tests/test-suite/math.js
+++ b/tests/test-suite/math.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/nextvar.js b/tests/test-suite/nextvar.js
index 28a54e7..ad75f93 100644
--- a/tests/test-suite/nextvar.js
+++ b/tests/test-suite/nextvar.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/pm.js b/tests/test-suite/pm.js
index 6b9c767..ae3512e 100644
--- a/tests/test-suite/pm.js
+++ b/tests/test-suite/pm.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/sort.js b/tests/test-suite/sort.js
index 0b13861..9cee400 100644
--- a/tests/test-suite/sort.js
+++ b/tests/test-suite/sort.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/strings.js b/tests/test-suite/strings.js
index c501ddd..50873e5 100644
--- a/tests/test-suite/strings.js
+++ b/tests/test-suite/strings.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/tpack.js b/tests/test-suite/tpack.js
index 0754532..ebce4e4 100644
--- a/tests/test-suite/tpack.js
+++ b/tests/test-suite/tpack.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/utf8.js b/tests/test-suite/utf8.js
index 2da2d4a..11f699d 100644
--- a/tests/test-suite/utf8.js
+++ b/tests/test-suite/utf8.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/test-suite/vararg.js b/tests/test-suite/vararg.js
index f693870..dc90248 100644
--- a/tests/test-suite/vararg.js
+++ b/tests/test-suite/vararg.js
@@ -2,8 +2,6 @@
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');
diff --git a/tests/tests.js b/tests/tests.js
index 6c799e5..b70a306 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -1,7 +1,5 @@
"use strict";
-global.WEB = false;
-
const lua = require("../src/lua.js");
const lauxlib = require("../src/lauxlib.js");
diff --git a/webpack.config.js b/webpack.config.js
index f44822a..3916cf2 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -30,7 +30,7 @@ module.exports = [
},
plugins: [
new webpack.DefinePlugin({
- WEB: JSON.stringify(true),
+ "typeof process": JSON.stringify("undefined")
})
]
}