I'm creating a simple terminal-based file manager on Node.js. Is there any way I can, from while my program is running on the terminal, quit it and open a file with VIM?
Simply:
require('child_process').spawn('vim', ['test.txt'], {stdio: 'inherit'});
If there is nothing left in the Node.js event loop when vim exits, then node will exit automatically as well. Or, if you need to guarantee node will exit when vim does:
var vim = require('child_process').spawn('vim', ['test.txt'], {stdio: 'inherit'});
vim.on('exit', process.exit);
As for closing the node application before vim exits, that's not really possible because vim inherits standard input/output/error streams from the spawning process (node) which are destroyed when node exits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With