since a while i am trying to reach something that doesn't work out for me so far.
With nodejs, i like to run a interactive sh-command and work with the sh-command output after the command has exited. i like to write a yieldable generator-function that wraps the running of the interactive shell command and returns the output of the shell command.
Approach 1: shelljs
- shelljs
- I had some success with shelljs, but at some point it wont run further.
- Question 1: is it possible to get shelljs to the point where i can inherit stdio and make the shelljs function yieldable?
Approach 2: child_process.spawnSync
- child_process.spawnSync
- at last i discovered child_process.spawnSync and was happy that, at least i can run interactive sh-commands without problems with
options: { stdio: 'inherit' }
- but i haven't found out how to get back the output of child_process.spawnSync.
- Question 2: How to wrap spawnSync into a generator function that returns the child_process's output?
Approach 3: co-child-process
- i also tried co-child-process.
- it seems to run, but not interactive with stdio. there is a issue regarding this, i dont really understand.
- Question 3: could someone explain me/ post a example how co-child-process will work with stdio inherit.
Approach 4: promisify child_process.spawn() with bluebird
- i opened an issue on bluebird if child_process.spawn() is promisifiable
So my question at all. Can someone post me an example of how to run a interactive shell command that can be wrapped in a yieldable generator function that returns the output of the shell command? i am open for new approaches.
I created a npm module which is available on github where you can fork it and contribute.
thx in advance.