refactor(cli): dedupe browser debug and download opts
This commit is contained in:
@@ -12,6 +12,20 @@ function runBrowserDebug(action: () => Promise<void>) {
|
||||
});
|
||||
}
|
||||
|
||||
function resolveDebugQuery(params: {
|
||||
targetId?: unknown;
|
||||
clear?: unknown;
|
||||
profile?: string;
|
||||
filter?: unknown;
|
||||
}) {
|
||||
return {
|
||||
targetId: typeof params.targetId === "string" ? params.targetId.trim() || undefined : undefined,
|
||||
filter: typeof params.filter === "string" ? params.filter.trim() || undefined : undefined,
|
||||
clear: Boolean(params.clear),
|
||||
profile: params.profile,
|
||||
};
|
||||
}
|
||||
|
||||
export function registerBrowserDebugCommands(
|
||||
browser: Command,
|
||||
parentOpts: (cmd: Command) => BrowserParentOpts,
|
||||
@@ -62,11 +76,11 @@ export function registerBrowserDebugCommands(
|
||||
{
|
||||
method: "GET",
|
||||
path: "/errors",
|
||||
query: {
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
clear: Boolean(opts.clear),
|
||||
query: resolveDebugQuery({
|
||||
targetId: opts.targetId,
|
||||
clear: opts.clear,
|
||||
profile,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{ timeoutMs: 20000 },
|
||||
);
|
||||
@@ -110,12 +124,12 @@ export function registerBrowserDebugCommands(
|
||||
{
|
||||
method: "GET",
|
||||
path: "/requests",
|
||||
query: {
|
||||
targetId: opts.targetId?.trim() || undefined,
|
||||
filter: opts.filter?.trim() || undefined,
|
||||
clear: Boolean(opts.clear),
|
||||
query: resolveDebugQuery({
|
||||
targetId: opts.targetId,
|
||||
filter: opts.filter,
|
||||
clear: opts.clear,
|
||||
profile,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{ timeoutMs: 20000 },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user