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,14 +1,13 @@
|
||||
import type { Command } from "commander";
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
|
||||
export { formatErrorMessage };
|
||||
|
||||
export type ManagerLookupResult<T> = {
|
||||
manager: T | null;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export function formatErrorMessage(err: unknown): string {
|
||||
return err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
|
||||
export async function withManager<T>(params: {
|
||||
getManager: () => Promise<ManagerLookupResult<T>>;
|
||||
onMissing: (error?: string) => void;
|
||||
|
||||
Reference in New Issue
Block a user