summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/loadlib.js')
-rw-r--r--src/loadlib.js29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index e7b1680..c2e867a 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -79,28 +79,23 @@ let readable = function(filename) {
return false;
};
// Only with Node
-if (typeof require === "function") {
+if (!WEB) {
- let fs = false;
- try {
- fs = require('fs');
- } catch (e) {}
+ const fs = require('fs');
- if (fs) {
- readable = function(filename) {
- let fd = false;
+ readable = function(filename) {
+ let fd = false;
- try {
- fd = fs.openSync(lua.to_jsstring(filename), 'r');
- } catch (e) {
- return false;
- }
+ try {
+ fd = fs.openSync(lua.to_jsstring(filename), 'r');
+ } catch (e) {
+ return false;
+ }
- fs.closeSync(fd);
+ fs.closeSync(fd);
- return true;
- };
- }
+ return true;
+ };
}