Skip to content

Commit 142b29d

Browse files
fix: address self-review — clone before mutating filterData, filter empty fields, consistent 429 exit code in health
Co-Authored-By: Chris K <ckorhonen@gmail.com>
1 parent 3e983d9 commit 142b29d

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ function getFilters(): OutputFilterOptions {
8787
maxItems?: string
8888
}>()
8989
return {
90-
fields: opts.fields?.split(",").map(f => f.trim()),
90+
fields: opts.fields
91+
?.split(",")
92+
.map(f => f.trim())
93+
.filter(Boolean),
9194
maxItems: opts.maxItems
9295
? parseIntOption(opts.maxItems, "--max-items")
9396
: undefined,

src/commands/health.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function healthCommand(getClient: () => OpenSeaClient): Command {
2626
2,
2727
),
2828
)
29-
process.exit(1)
29+
process.exit(error.statusCode === 429 ? 3 : 1)
3030
}
3131
console.error(
3232
JSON.stringify(

src/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function filterData(
2020
result &&
2121
typeof result === "object"
2222
) {
23-
const obj = result as Record<string, unknown>
23+
const obj = { ...(result as Record<string, unknown>) }
2424
for (const [key, value] of Object.entries(obj)) {
2525
if (Array.isArray(value)) {
2626
obj[key] = value.slice(0, options.maxItems)

0 commit comments

Comments
 (0)