Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Commit

Permalink
feat(core): migrated to console.table
Browse files Browse the repository at this point in the history
This allows cross platform tables to be printed to the console. Previously
console-table-printer would print ascii and windows wouldn't display it
correctly.
  • Loading branch information
markmcdowell committed Jun 19, 2020
1 parent 4c4fea2 commit 3da5696
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"bufferutil": "^4.0.1",
"clean-webpack-plugin": "^3.0.0",
"compression": "^1.7.4",
"console-table-printer": "^1.5.3",
"copy-webpack-plugin": "^6.0.2",
"copyfiles": "^2.3.0",
"cors": "^2.8.5",
Expand Down
24 changes: 8 additions & 16 deletions packages/desktop-core/src/main/commands/ps/handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IConfiguration } from "@reactivemarkets/desktop-types";
import { Table } from "console-table-printer";
import { app } from "electron";
import { ReservedChannels } from "../../../common";
import { logger } from "../../logging";
Expand All @@ -20,27 +19,20 @@ export const handler = async (options: IPsOptions) => {
if (options.quiet) {
containers.forEach((c) => logger.info(`${c.metadata.uid}`));
} else {
const details = containers.map((c) => {
return {
id: c.metadata.uid,
const details = containers.reduce((prev, c) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
prev[c.metadata.uid] = {
name: c.metadata.name,
namespace: c.metadata.namespace,
kind: c.kind,
created: c.status?.startTime,
};
});

const table = new Table({
columns: [
{ name: "id", alignment: "left" },
{ name: "name", alignment: "left" },
{ name: "namespace", alignment: "left" },
{ name: "kind", alignment: "left" },
{ name: "created" },
],
});
table.addRows(details);
table.printTable();
return prev;
}, {});

console.table(details);
}

app.exit();
Expand Down

0 comments on commit 3da5696

Please sign in to comment.