OK, so I have been working on a console input system for a project workflow and user input. I am getting frustrated as there seems to be no actual answer to this simple problem. Currently I wrote simple modules to handle user input but the problem is when I throw a check answer, it executes them parallel to my read input. Here is the module that prompts a bool question:
exports.bool = function(question){
ret = null;
answer = ['y','n']
inquery.question(`> ${question} [${answer}] `, (out) => {
ret = out;
inquery.close();
});
if (ret == 'y')
return true;
else
return false;
}
And then here is the part I'm asking for how do they want to setup:
async function main(){
themes = rw.listFiles('./gp-content/gp-themes');
config = './gp-config.json';
answer = await inquery.bool('Setup new environment?');
console.log(answer);
if (answer)
initiate();
else
buildPages();
}
& when I execute I expect:
Setup new environment? [y,n] y true
But I get:
Setup new environment? [y,n] false y
I'm sorry if this is a repeated question but there wasn't a straight answer for this problem. So I appreciate any new methods or feedback in understanding Async better. Also I am trying to avoid using timeout as it seems to be obsolete.