mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 02:01:16 +00:00
refactor: dedupe config cli command trimmed readers
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
import type { GatewayServiceRuntime } from "../../daemon/service-runtime.js";
|
||||
import { loadNodeHostConfig } from "../../node-host/config.js";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { normalizeOptionalString } from "../../shared/string-coerce.js";
|
||||
import { colorize } from "../../terminal/theme.js";
|
||||
import { formatCliCommand } from "../command-format.js";
|
||||
import {
|
||||
@@ -76,7 +77,7 @@ function resolveNodeDefaults(
|
||||
opts: NodeDaemonInstallOptions,
|
||||
config: Awaited<ReturnType<typeof loadNodeHostConfig>>,
|
||||
) {
|
||||
const host = opts.host?.trim() || config?.gateway?.host || "127.0.0.1";
|
||||
const host = normalizeOptionalString(opts.host) || config?.gateway?.host || "127.0.0.1";
|
||||
const portOverride = parsePort(opts.port);
|
||||
if (opts.port !== undefined && portOverride === null) {
|
||||
return { host, port: null };
|
||||
@@ -127,7 +128,8 @@ export async function runNodeDaemonInstall(opts: NodeDaemonInstallOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tlsFingerprint = opts.tlsFingerprint?.trim() || config?.gateway?.tlsFingerprint;
|
||||
const tlsFingerprint =
|
||||
normalizeOptionalString(opts.tlsFingerprint) || config?.gateway?.tlsFingerprint;
|
||||
const tls = Boolean(opts.tls) || Boolean(tlsFingerprint) || Boolean(config?.gateway?.tls);
|
||||
const { programArguments, workingDirectory, environment, description } =
|
||||
await buildNodeInstallPlan({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Command } from "commander";
|
||||
import { loadNodeHostConfig } from "../../node-host/config.js";
|
||||
import { runNodeHost } from "../../node-host/runner.js";
|
||||
import { normalizeOptionalString } from "../../shared/string-coerce.js";
|
||||
import { formatDocsLink } from "../../terminal/links.js";
|
||||
import { theme } from "../../terminal/theme.js";
|
||||
import { parsePort } from "../daemon-cli/shared.js";
|
||||
@@ -48,7 +49,9 @@ export function registerNodeCli(program: Command) {
|
||||
.action(async (opts) => {
|
||||
const existing = await loadNodeHostConfig();
|
||||
const host =
|
||||
(opts.host as string | undefined)?.trim() || existing?.gateway?.host || "127.0.0.1";
|
||||
normalizeOptionalString(opts.host as string | undefined) ||
|
||||
existing?.gateway?.host ||
|
||||
"127.0.0.1";
|
||||
const port = parsePortWithFallback(opts.port, existing?.gateway?.port ?? 18789);
|
||||
await runNodeHost({
|
||||
gatewayHost: host,
|
||||
|
||||
Reference in New Issue
Block a user