Skip to content

Commit

Permalink
Fix tiny bug where list command failed when given no backend resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
taeold committed Dec 4, 2023
1 parent c031540 commit 3ee867c
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/commands/frameworks-backends-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ import { bold } from "colorette";

const Table = require("cli-table");

Check warning on line 9 in src/commands/frameworks-backends-list.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value

Check warning on line 9 in src/commands/frameworks-backends-list.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Require statement not part of import statement
const COLUMN_LENGTH = 20;
const TABLE_HEAD = [
"Backend Id",
"Repository Name",
"Location",
"URL",
"Created Date",
"Updated Date",
];
const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
export const command = new Command("backends:list")
.description("List backends of a Firebase project.")
.option("-l, --location <location>", "App Backend location", "-")
Expand All @@ -27,11 +20,11 @@ export const command = new Command("backends:list")
style: { head: ["green"] },
});
table.colWidths = COLUMN_LENGTH;

Check warning on line 22 in src/commands/frameworks-backends-list.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .colWidths on an `any` value
const backendsList: gcp.ListBackendsResponse[] = [];
const backendsList: gcp.Backend[] = [];
try {
const backendsPerRegion = await gcp.listBackends(projectId, location);
backendsList.push(backendsPerRegion);
populateTable(backendsPerRegion, location, table);
backendsList.push(...backendsPerRegion.backends);
populateTable(backendsList, table);

logger.info();
logger.info(`Backends for project ${bold(projectId)}`);
Expand All @@ -47,8 +40,8 @@ export const command = new Command("backends:list")
return backendsList;
});

function populateTable(backendsLists: gcp.ListBackendsResponse, location: string, table: any) {
for (const backend of backendsLists.backends) {
function populateTable(backends: gcp.Backend[], table: any) {
for (const backend of backends) {
const [location, , backendId] = backend.name.split("/").slice(3, 6);
const entry = [
backendId,
Expand Down

0 comments on commit 3ee867c

Please sign in to comment.