Git Product home page Git Product logo

fengari-node-cli's Introduction

Build Status npm License: MIT #fengari on libera.chat

fengari-node-cli

The Lua command line application, but using fengari under node.js

This project consists of fengari and fengaric command line applications that provide functionality equivalent to the lua and luac programs.

Installation

Use npm or yarn:

npm install -g fengari-node-cli

Usage

usage: fengari [options] [script [args]]
Available options are:
  -e stat  execute string 'stat'
  -i       enter interactive mode after executing 'script'
  -l name  require library 'name'
  -v       show version information
  -E       ignore environment variables
  --       stop handling options
  -        stop handling options and execute stdin
usage: fengaric [options] [filename]
Available options are:
  -l       list (use -l -l for full listing)
  -o name  output to file 'name' (default is "fengaric.out")
  -p       parse only
  -s       strip debug information
  -v       show version information
  --       stop handling options
  -        stop handling options and process stdin

fengari-node-cli's People

Contributors

daurnimator avatar giann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fengari-node-cli's Issues

Failure to read a Lua file

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.

lua-cli should print items as they are tostringed

Migrated from fengari-lua/fengari#50

lua-cli should print items as it goes rather than saving them up.
This matters if someone creates an object like: setmetatable({}, {__tostring=function() os.exit(1) end})

$ lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> a=setmetatable({}, {__tostring=function() os.exit(1) end})
> "foo", a, "bar"
foo$
$ fengari 
Fengari 0.0.1  Copyright (C) 2017 B. Giannangeli, Daurnimator
Based on: Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> a=setmetatable({}, {__tostring=function() os.exit(1) end})
> "foo"
foo
> "foo", "bar"
foo	bar
> "foo", a, "bar"
$

Is the bytecode produced by fengaric supposed to be compatible with lua?

Hello,

I've tried to re-use the bytecode produced by fengaric in lua and it doesn't seem to work, so I'm wondering if it's supposed to, or if my lua version is incompatible or if there's a way to do it?

I made sure to use lua 5.3 (tested with 5.3.0 and 5.3.5) but the bytecode seems to differ

$ cat test.lua
print('hello')
$ fengaric -o test.o test.lua
$ ./lua-5.3/lua -v
Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
$ ./lua-5.3/lua test.o
lua: test.o: size_t size mismatch in precompiled chunk

vs

$ ./lua-5.3/luac -o test.o test.lua
$ ./lua-5.3/lua test.o
hello
$ fengaric -o test.o test.lua
$ fengari test.o
hello

To give more context, i'd like to send the bytecode version from nodejs (as a buffer) to program running in C that embeds the lua compiler.

"No compatible version found: fengari@^0.0.1"

Including here a log of accidentally installing 'fengari' globally (which actually happens to confirm that [email protected] is installable) and uninstalling it, checking node version then trying to install 'fengari-node-cli':

[nikki ~]$ npm i -g fengari
/Users/nikki/.nvm/versions/node/v8.4.0/lib
└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

[nikki ~]$ node -v
v8.4.0
[nikki ~]$ clear
[nikki ~]$ npm uninstall -g fengari
- [email protected] node_modules/fengari/node_modules/os-tmpdir
- [email protected] node_modules/fengari/node_modules/readline-sync
- [email protected] node_modules/fengari/node_modules/sprintf-js
- [email protected] node_modules/fengari/node_modules/strftime
- [email protected] node_modules/fengari/node_modules/tmp
- [email protected] node_modules/fengari
[nikki ~]$ npm i -g fengari-node-cli
npm ERR! code ETARGET
npm ERR! notarget No compatible version found: fengari@^0.0.1
npm ERR! notarget Valid install targets:
npm ERR! notarget 0.0.1-rc.1
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'fengari-node-cli'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nikki/.npm/_logs/2018-03-30T22_01_55_817Z-debug.log

^0.0.1 doesn't match 0.0.1-rc.1 according to https://semver.npmjs.com/ (note how the first image shows the box containing '0.0.1-rc.1' in green while the second doesn't):
screenshot 2018-03-30 15 05 11
screenshot 2018-03-30 15 05 49

file:write() handles only the first argument and transforms it.

file:write() handles only the first argument and transforms it.

$ fengari
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
> io.stdout:write 'foo'
102,111,111null
> s = 'foo'; print(table.concat({string.byte(s, 1, #s)}, ','))
102,111,111
> io.stdout:write(1, 2)
49null
> io.stdout:write('a', 'b')
97null

$ node -v
v6.11.4

how can I call node.js api from fengari?

npm install -g fengari-node-cli
fengari some_lua_file.lua

works great, but I want to call node.js function from lua, such as net module function, how can I do that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.