mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor: consolidate async timing helpers (#99721)
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
redactForDevToolLog,
|
||||
redactHomePath,
|
||||
} from "../lib/dev-tooling-safety.ts";
|
||||
import { sleep } from "../lib/sleep.mjs";
|
||||
|
||||
function writeStdoutLine(message: string): void {
|
||||
process.stdout.write(`${message}\n`);
|
||||
@@ -157,12 +158,6 @@ class CliArgumentError extends Error {
|
||||
override name = "CliArgumentError";
|
||||
}
|
||||
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
function remainingTimeoutMs(deadlineMs: number, nowMs = Date.now()): number {
|
||||
const remaining = Math.floor(deadlineMs - nowMs);
|
||||
if (!Number.isFinite(deadlineMs) || remaining <= 0) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { mkdir, open, writeFile } from "node:fs/promises";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { sleep as delay } from "../lib/sleep.mjs";
|
||||
import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs";
|
||||
|
||||
type Options = {
|
||||
@@ -119,12 +120,6 @@ function parseOptions(args = process.argv.slice(2)): Options {
|
||||
};
|
||||
}
|
||||
|
||||
function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
function shouldUseAltScreen(options: Options) {
|
||||
return options.altScreen && process.stdout.isTTY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user