Skip to content

Commit e7dfd5b

Browse files
committed
Fix tiny bug where list command failed when given no backend resources.
1 parent 6036dfb commit e7dfd5b

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/commands/frameworks-backends-list.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import { bold } from "colorette";
88

99
const Table = require("cli-table");
1010
const COLUMN_LENGTH = 20;
11-
const TABLE_HEAD = [
12-
"Backend Id",
13-
"Repository Name",
14-
"Location",
15-
"URL",
16-
"Created Date",
17-
"Updated Date",
18-
];
11+
const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
1912
export const command = new Command("backends:list")
2013
.description("List backends of a Firebase project.")
2114
.option("-l, --location <location>", "App Backend location", "-")
@@ -27,11 +20,11 @@ export const command = new Command("backends:list")
2720
style: { head: ["green"] },
2821
});
2922
table.colWidths = COLUMN_LENGTH;
30-
const backendsList: gcp.ListBackendsResponse[] = [];
23+
const backendsList: gcp.Backend[] = [];
3124
try {
3225
const backendsPerRegion = await gcp.listBackends(projectId, location);
33-
backendsList.push(backendsPerRegion);
34-
populateTable(backendsPerRegion, location, table);
26+
backendsList.push(...backendsPerRegion.backends);
27+
populateTable(backendsList, table);
3528

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

50-
function populateTable(backendsLists: gcp.ListBackendsResponse, location: string, table: any) {
51-
for (const backend of backendsLists.backends) {
43+
function populateTable(backends: gcp.Backend[], table: any) {
44+
for (const backend of backends) {
5245
const [location, , backendId] = backend.name.split("/").slice(3, 6);
5346
const entry = [
5447
backendId,

0 commit comments

Comments
 (0)