我正在尝试使用readline进行“可选”输入,但我不确定如何在readline等待输入的同时允许代码在后台运行。我无法通过搜索找到任何东西,但后来我可能正在寻找错误的东西。
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Options:\n [1] Files processed (total)\n [2] Files processed (session)', function(answer) => {
});
con.connect(function(err) {
if(err) throw err;
console.log("Connected to database");
fs.watch(basedir, (event, filename) => {
if(filename && filetype.includes(getType(filename))) {
console.log("Found file with type: " + getType(filename));
if(getType(filename) == "zip") {
}
}
});
});
基本上,我想在整个时间内提供问题,同时连续运行con.connect方法