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