fengari-lua / fengari-node-cli

The Lua command line application, but using fengari under node.js
MIT License
29 stars 6 forks source link

Failure to read a Lua file #5

Closed fperrad closed 6 years ago

fperrad commented 6 years ago

With my configuration, I obtain a nodejs error.

$ lsb_release -d
Description:    Ubuntu 17.10
$ nodejs -v
v6.11.4
$ fengari -v
Fengari 0.1.0  Copyright (C) 2017-2018 B. Giannangeli, Daurnimator
Based on: Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
$ cat file.lua 
print 'foo'
$ fengari file.lua 
cannot read file.lua: Unknown encoding: 1024
(node:5600) DeprecationWarning: fs.readSync's legacy String interfaceis deprecated. Use the Buffer API as mentioned in the documentation instead.
giann commented 6 years ago

I can't reproduce. What did you use to write your file.lua ? Sounds like an odd character is in there.

fperrad commented 6 years ago

I created file.lua with vim.

$ hexdump -C file.lua 
00000000  70 72 69 6e 74 20 27 66  6f 6f 27 0a              |print 'foo'.|
0000000c
fperrad commented 6 years ago

On Travis CI, you exercise only against node v8.11.1 & v9.10.1

daurnimator commented 6 years ago

Looks like node only gained support for Uint8Array in fs.readSync in version 7. See https://nodejs.org/docs/latest-v6.x/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position vs https://nodejs.org/docs/latest-v7.x/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position

daurnimator commented 6 years ago

Test suite passes in node 7. Test suite has 11 failures in node 6; caused by:

daurnimator commented 6 years ago

@fperrad will be included in next fengari core point release. fengari-node-cli installed after that point in time will have the bug fixed. Let us know if you find anything else :)