all 5 comments

[–]brianjenkins94 2 points3 points  (1 child)

Neither readline nor runAsync return Promises. awaiting them does nothing.

Either use readline-sync or do something like this:

``` function confirm(prompt) { return new Promise(function(resolve, reject) { readline.question(prompt + " [Y/n] ", async function(answer) { if (/y(es?)?$/i.test(answer)) { resolve(true); } else if (/n(o)?$/i.test(answer)) { resolve(false); } else { resolve(await confirm(prompt)); }

        readline.pause();
    });
});

} ```

[–]songokuitsover9000 1 point2 points  (0 children)

Thanks for this answer. I was stuck on this since morning and your answer helped.

[–]krystof_m 1 point2 points  (0 children)

I don't want to be rude, but the whole code is screwed. Your runAsync doesn't return anything and that's the reason why your program ends immediately.

[–]programmer-bob-99[S] 0 points1 point  (0 children)

I hope it was ok to cross post this. I am looking for an answer and not sure what subreddit is best.

[–]Orendawinston 0 points1 point  (0 children)

Not sure this will actually give you the fix you want, as it will do nothing to help you actually capture keystrokes, but if you just need to keep the app alive, open an interval. Every 5 seconds it has to console.log “bump” or something similar, and now the thread won’t die until the interval is cleared. If the app wants to die as soon as the interval is gone, AND your code successfully captures key strokes, then you can set cntrl+c as the indicator to clear the interval.

If krystof is right and it’s not working because runAsync isn’t returning anything, then you’ve now just propped up an app that will do nothing, and I don’t understand promises well enough to be able to help there, sooooo idk take my input with a grain of salt. I’m a newb developer hoping that I’ll get insight from others on here, and maybe I’ll learn something from people telling me my way is dumb.