Reputation: 445
I am creating make node CLI automate my npm package publishing, I am struck by this problem. After all Confirmation, I want to run the command semantic-release
but problem it has its own prompts
I currently use exec command but It does not show any prompts created by semantic-release
Code
const timer = showLoading(`running ${chalk.blue(command)} `);
exec(command, (error, stdout, stderr) => {
process.stdout.write(chalk.dim(`\r running ${chalk.blue(command)} `));
clearInterval(timer);
defaults.onFinish();
if (error) {
defaults.onError(error);
console.log(error);
}
defaults.onSuccess(stdout);
console.log(stdout);
});
Upvotes: 2
Views: 406
Reputation: 4483
You can show the prompts by spawning a synchronous child process that inherits it's stdio
pipes from the parent process.
import { spawnSync } from 'child_process';
let { status } = spawnSync('./test.sh', [], { stdio: 'inherit' });
if (status > 0) { throw new Error('spawned process exited abnormally'); }
#!/bin/bash
read -p 'enter something: ' value
[ -z "$value" ] && exit 1
echo "$value"
Upvotes: 2
Reputation: 326
I have used this way to create my own CLI
, it's an easy way to create all the commands that I want and to do what I want, check the link maybe that helps you, in the website there also good explanation with images
Upvotes: -1