refactor: 🚨 Remove process.exit usage

This commit is contained in:
Jesse Wierzbinski 2024-10-03 11:59:26 +02:00
parent b1d8595a7c
commit 076e930369
No known key found for this signature in database
8 changed files with 22 additions and 45 deletions

View file

@ -150,6 +150,10 @@ export const configValidator = z.object({
enabled: false,
address: "",
})
.refine(
(arg) => !arg.enabled || !!arg.address,
"When proxy is enabled, address must be set",
)
.transform((arg) => ({
...arg,
address: arg.enabled ? arg.address : undefined,

View file

@ -23,10 +23,7 @@ const parsed = await configValidator.safeParseAsync(config);
if (!parsed.success) {
console.error("Invalid config file:");
console.error(fromZodError(parsed.error).message);
// Hang until Ctrl+C is pressed
await Bun.sleep(Number.POSITIVE_INFINITY);
process.exit();
throw fromZodError(parsed.error).message;
}
const exportedConfig = parsed.data;