jprichardson / node-suppose

Like UNIX Expect, but for Node.js.
MIT License
252 stars 28 forks source link

Offer TTYs to processes #27

Open piranna opened 7 years ago

piranna commented 7 years ago

Seems Docker needs that terminal to be a TTY to allow to enable both the -i and -t flags, but node-suppose is using regular streams. Probably it would be needed to use pty.js to enable them.

jprichardson commented 7 years ago

Great idea!

piranna commented 7 years ago

node-suppose now works using node-pty, but it's fairly unstable on the output checking, probably due to hiddend ANSI characters or invisible ones, specially end of lines. Usage of regular expressions and clean-up of outputs solve it up to some point, but probably would be better to use Buffer objects instead of strings and use a monitor tool to store exactly the full output for inspection.

piranna commented 7 years ago

Ok, this need some improvement specially for testing, but it works :-) I have been able to trick Docker to use -t flag and test NodeOS on Docker without needed special cases :-D

ghost commented 7 years ago

Hello, i try use docker exec -it command but it doesn't work. I have the input device is not a TTY error message.

suppose('docker', ['exec', '-it', 'container_name', 'command'], { debug: fs.createWriteStream('/tmp/debug.txt') })
  .when('test').respond('yes\n')
  .on('error', function(err) {
    console.log(err.message);
  })
  .end(function(code) {
    console.log(code);
  })

Thanks for your help.

piranna commented 7 years ago

What version are you using? TTY is only currently available in master, not in npm.

ghost commented 7 years ago

Ok, my bad. Thanks for your quick response.

dackmin commented 6 years ago

@piranna great news 😄 when do you plan on publishing it to npm ?

piranna commented 6 years ago

@piranna great news when do you plan on publishing it to npm ?

Problem is that although it's working tests are unstable, so I would like to have them before publishing a new version. I have been very busy in the last months, if you would be able to take a look at them and do a pull-request maybe we can move it forward :-)