SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.09k stars 1.3k forks source link

How to Interact with Inquirer when execute command with child_process.exec? #990

Closed lamysafari closed 1 month ago

lamysafari commented 3 years ago

for exampple: `const process = exec('some-cli', option, (error, stdout, stderr) => {

})` some-cli uses inquirer how can I interact with It to get output and send input?

SBoudrias commented 1 month ago

You'd need to send keypress events to the stdin stream of the spawned process. Kinda like how we handle it in @inquirer/testing; see https://github.com/SBoudrias/Inquirer.js/blob/main/packages/testing/src/index.mts#L73