Skip to content

Commit fc2c19f

Browse files
committed
CR: Fix --issue-type option to handle single values
Commander.js returns a string for single values and an array for multiple values with variadic options. Normalize to array before iterating to prevent iterating over characters of a string.
1 parent 62f7663 commit fc2c19f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/commands/crashlytics-reports-get.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,18 @@ export const command = new Command("crashlytics:reports:get <report>")
155155
filter.issueVariantId = options.issueVariantId;
156156
}
157157
if (options.issueType) {
158-
for (const issueType of options.issueType) {
158+
const issueTypes = Array.isArray(options.issueType)
159+
? options.issueType
160+
: [options.issueType];
161+
for (const issueType of issueTypes) {
159162
const issueTypeUpper = issueType.toUpperCase();
160163
if (!VALID_ISSUE_TYPES.includes(issueTypeUpper as (typeof VALID_ISSUE_TYPES)[number])) {
161164
throw new FirebaseError(
162165
`Invalid issue type "${issueType}". Must be one of: ${VALID_ISSUE_TYPES.join(", ")}`,
163166
);
164167
}
165168
}
166-
filter.issueErrorTypes = options.issueType.map((e) => e.toUpperCase()) as (
169+
filter.issueErrorTypes = issueTypes.map((e) => e.toUpperCase()) as (
167170
| "FATAL"
168171
| "NON_FATAL"
169172
| "ANR"

0 commit comments

Comments
 (0)