dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

When showing vorpal from inside a callback ctrl-c twice does not exit #70

Closed sarus closed 8 years ago

sarus commented 8 years ago

I'm running some async init code before I show vorpal and so ctrl-c twice no longer exits vorpal as I'm stuck in my callback. The idea here is that I only want to run vorpal if I can successfully connect to a database since all the vorpal commands are db related.

// basic setup
testConnection(function(err, result){
   if(!err){
        vorpal.show();
   }
});

Is there an event or callback I can listen for to know when vorpal exists? Right now hitting ctrl-c appears to be stopping vorpal but Node is sitting in my callback waiting for something. I realize I might also have this setup wrong.

If I add the following:

process.on('SIGINT', () => process.exit(2));

Then I can get my program to quit if I hti ctrl-c three times. Otherwise I have to kill -9 it.

Thanks!

dthree commented 8 years ago

Dude you confused the hell out of me for about 2 seconds with your avatar...

eliperelman commented 8 years ago

Haha nice.

dthree commented 8 years ago

Related:

https://github.com/dthree/vorpal/issues/55 https://github.com/dthree/vorpal/issues/44 https://github.com/dthree/vorpal/issues/42 https://github.com/dthree/vorpal/issues/45

This is apparently the issue of the day.

sarus commented 8 years ago

@dthree haha. I was super confused when I first came across this repo as well. You have good taste though.

dthree commented 8 years ago

Haha - as you do. Even our positioning is the same...

dthree commented 8 years ago

Fixed!! v1.5.2.

See https://github.com/dthree/vorpal/issues/55