Is there a way to get this to work with a pre-commit hook?
I have a simple pre-commit hook that asks the user for the semantic version of their commit:
'use strict';
const { exec } = require('child_process');
const { promisify } = require('util')
const inquirer = require('inquirer');
const asyncExec = promisify(exec);
const question = {
type: 'list',
name: 'version',
message: 'Semantic Version?',
choices: ['Patch', 'Minor', 'Major'],
filter(val) {
return val.toLowerCase();
},
};
(async () => {
const { version } = await inquirer.prompt(question);
await asyncExec(`npm version ${version} --no-git-tag-version`);
})();
It appears the pre-commit hook doesn't wait for inquirer to finish. It shows the prompt but doesn't allow the user to interact with it as the hook thinks it's finished.

The pre-commit hook is using husky which calls "version:select": "node ./scripts/versionSelect.js",.
Maybe this is an issue with Husky? I would have thought this might be a common use case for this library though so maybe others have come across this issue?
Thanks
You'll need to make sure the sub-process you boot has access to the stdin/out of the main process for it to be interactive. This might only work with spawnSync passing the right stdio option.
And it might need some special configuration on Husky; but I'm not 100% sure how it works for them.
@stretch0 you can try to check this past issue: https://github.com/SBoudrias/Inquirer.js/issues/518
The exec < /dev/tty trick worked for me.
Moved instructions for this to the README https://github.com/SBoudrias/Inquirer.js#using-as-pre-commitgit-hooks-or-scripts
Feel free to send a PR to clarify the doc if anything would've helped you when you ran into this problem! Cheers