mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:21:23 +00:00
refactor: consolidate duplicate utility functions (#12439)
* refactor: consolidate duplicate utility functions - Add escapeRegExp to src/utils.ts and remove 10 local duplicates - Rename bash-tools clampNumber to clampWithDefault (different signature) - Centralize formatError calls to use formatErrorMessage from infra/errors.ts - Re-export formatErrorMessage from cli/cli-utils.ts to preserve API * refactor: consolidate remaining escapeRegExp duplicates * refactor: consolidate sleep, stripAnsi, and clamp duplicates
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { stripAnsi } from "../terminal/ansi.js";
|
||||
import { formatHealthCheckFailure } from "./health-format.js";
|
||||
|
||||
const ansiEscape = String.fromCharCode(27);
|
||||
const ansiRegex = new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g");
|
||||
const stripAnsi = (input: string) => input.replace(ansiRegex, "");
|
||||
|
||||
describe("formatHealthCheckFailure", () => {
|
||||
it("keeps non-rich output stable", () => {
|
||||
const err = new Error("gateway closed (1006 abnormal closure): no close reason");
|
||||
|
||||
Reference in New Issue
Block a user