fix sleep issue
This commit is contained in:
parent
956b0d9751
commit
7ff0c23c8a
11
util.ts
11
util.ts
@ -4,12 +4,11 @@ export function sleepWithCountdown(seconds: number): Promise<void> {
|
||||
|
||||
const update = () => {
|
||||
const msg = `⏳ Waiting ${remaining}s...`;
|
||||
process.stdout.clearLine(0); // Clear current line
|
||||
process.stdout.cursorTo(0); // Move cursor to start of line
|
||||
process.stdout.write(msg); // Write message
|
||||
const padded = msg.padEnd(30, " "); // make sure old content is erased
|
||||
process.stdout.write(`\r${padded}`);
|
||||
};
|
||||
|
||||
update(); // Initial message
|
||||
update(); // initial print
|
||||
|
||||
const interval = setInterval(() => {
|
||||
remaining--;
|
||||
@ -18,9 +17,7 @@ export function sleepWithCountdown(seconds: number): Promise<void> {
|
||||
update();
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
process.stdout.clearLine(0);
|
||||
process.stdout.cursorTo(0);
|
||||
process.stdout.write(`✅ Resuming now\n`);
|
||||
process.stdout.write(`\r✅ Resuming now \n`);
|
||||
resolve();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user