waitAnyKey

This commit is contained in:
nobug
2023-12-10 22:55:44 +08:00
parent 7d06bcd808
commit e615d671d0
2 changed files with 35 additions and 25 deletions

12
waitAnyKey.ts Normal file
View File

@ -0,0 +1,12 @@
export default function waitAnyKey() {
console.log('Press any key to continue...');
return new Promise(resolve => {
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.once('data', () => {
process.stdin.setRawMode(false);
process.stdin.pause(); // 在这里添加
resolve(undefined);
});
});
}