summaryrefslogtreecommitdiff
path: root/src/ldblib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-09 11:36:14 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-09 11:36:14 +0200
commit697ef457e1b0eabd3aa9fb2332a5d04478b39603 (patch)
tree4d93ec7e3d1cc698a5c54de9785d688bf510ed15 /src/ldblib.js
parent3e439ed653093e6e124a4997f64053164f1043b8 (diff)
downloadfengari-697ef457e1b0eabd3aa9fb2332a5d04478b39603.tar.gz
fengari-697ef457e1b0eabd3aa9fb2332a5d04478b39603.tar.bz2
fengari-697ef457e1b0eabd3aa9fb2332a5d04478b39603.zip
Webpack (single bundle for now)
Diffstat (limited to 'src/ldblib.js')
-rw-r--r--src/ldblib.js57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/ldblib.js b/src/ldblib.js
index fbf31e8..90f08cd 100644
--- a/src/ldblib.js
+++ b/src/ldblib.js
@@ -397,40 +397,33 @@ const dblib = {
};
// Only with Node
-if (typeof require === "function") {
- let fs = false;
- try {
- fs = require('fs');
- } catch (e) {}
-
- if (fs) {
- const readlineSync = require('readline-sync');
- readlineSync.setDefaultOptions({
- prompt: 'lua_debug> '
- });
-
- // TODO: if in browser, use a designated input in the DOM ?
- const db_debug = function(L) {
- for (;;) {
- let input = readlineSync.prompt();
-
- if (input === "cont")
- return 0;
-
- if (input.length === 0)
- continue;
-
- let buffer = lua.to_luastring(input);
- if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, lua.to_luastring("=(debug command)", true))
- || lua.lua_pcall(L, 0, 0, 0)) {
- lauxlib.lua_writestringerror(`${lua.lua_tojsstring(L, -1)}\n`);
- }
- lua.lua_settop(L, 0); /* remove eventual returns */
+if (!WEB) {
+ const readlineSync = require('readline-sync');
+ readlineSync.setDefaultOptions({
+ prompt: 'lua_debug> '
+ });
+
+ // TODO: if in browser, use a designated input in the DOM ?
+ const db_debug = function(L) {
+ for (;;) {
+ let input = readlineSync.prompt();
+
+ if (input === "cont")
+ return 0;
+
+ if (input.length === 0)
+ continue;
+
+ let buffer = lua.to_luastring(input);
+ if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, lua.to_luastring("=(debug command)", true))
+ || lua.lua_pcall(L, 0, 0, 0)) {
+ lauxlib.lua_writestringerror(`${lua.lua_tojsstring(L, -1)}\n`);
}
- };
+ lua.lua_settop(L, 0); /* remove eventual returns */
+ }
+ };
- dblib.debug = db_debug;
- }
+ dblib.debug = db_debug;
}
const luaopen_debug = function(L) {