chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -8,30 +8,48 @@ import { defaultRuntime } from "../../runtime.js";
|
||||
import { formatCliCommand } from "../command-format.js";
|
||||
|
||||
export function parsePort(raw: unknown): number | null {
|
||||
if (raw === undefined || raw === null) return null;
|
||||
if (raw === undefined || raw === null) {
|
||||
return null;
|
||||
}
|
||||
const value =
|
||||
typeof raw === "string"
|
||||
? raw
|
||||
: typeof raw === "number" || typeof raw === "bigint"
|
||||
? raw.toString()
|
||||
: null;
|
||||
if (value === null) return null;
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
const parsed = Number.parseInt(value, 10);
|
||||
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
||||
if (!Number.isFinite(parsed) || parsed <= 0) {
|
||||
return null;
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
export const toOptionString = (value: unknown): string | undefined => {
|
||||
if (typeof value === "string") return value;
|
||||
if (typeof value === "number" || typeof value === "bigint") return value.toString();
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "number" || typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export function describeUnknownError(err: unknown): string {
|
||||
if (err instanceof Error) return err.message;
|
||||
if (typeof err === "string") return err;
|
||||
if (typeof err === "number" || typeof err === "bigint") return err.toString();
|
||||
if (typeof err === "boolean") return err ? "true" : "false";
|
||||
if (err instanceof Error) {
|
||||
return err.message;
|
||||
}
|
||||
if (typeof err === "string") {
|
||||
return err;
|
||||
}
|
||||
if (typeof err === "number" || typeof err === "bigint") {
|
||||
return err.toString();
|
||||
}
|
||||
if (typeof err === "boolean") {
|
||||
return err ? "true" : "false";
|
||||
}
|
||||
if (err && typeof err === "object") {
|
||||
if ("message" in err && typeof err.message === "string") {
|
||||
return err.message;
|
||||
@@ -94,7 +112,9 @@ export async function maybeExplainGatewayServiceStop() {
|
||||
} catch {
|
||||
loaded = null;
|
||||
}
|
||||
if (loaded === false) return;
|
||||
if (loaded === false) {
|
||||
return;
|
||||
}
|
||||
defaultRuntime.error(
|
||||
loaded
|
||||
? `Gateway service appears ${service.loadedText}. Stop it first.`
|
||||
|
||||
Reference in New Issue
Block a user