Been trying to respond to a CLI tool which prompts two questions before running so I tried to create a script for automation. Problem is: respond is not submitted. Searched this for hours and literally read every other stackoverflow question about this topic but none of these solutions seems to work. here's my code:
const moralis = spawn(
`moralis-admin-cli connect-local-devchain --moralisApiKey ${process.env.MORALIS_API_KEY} --moralisApiSecret ${process.env.MORALIS_API_SECRET} --frpcPath ${process.env.FRPC_PATH}`,
{
shell: true,
}
);
moralis.stdout.setEncoding("utf8");
moralis.stdout.pipe(process.stdout);
moralis.stdout.on("data", function (data) {
if (data.includes("What server")) {
moralis.stdin.write("0" + "\n");
moralis.stdin.end();
}
});
running that just prints the prompt of the CLI tool and doesn't submit anything. If I use process.stdin.write it actually prints the 0 response but also doesn't submit it. From my understand the end call should actually submit my response? Also why don't I see the response in shell when I use moralis.stdin.write?
cheers!