cli-table / cli-table3

Pretty unicode tables for the command line
MIT License
515 stars 44 forks source link

Hangs if Teminal Image is inserted in a row #331

Closed ttessarolo closed 10 months ago

ttessarolo commented 10 months ago

The execution hangs if an image form terminal-image is part of a row: Here's an extract of the code that hangs:

import terminalImage from "terminal-image";
import got from "got";
import Table from "cli-table3";

 var table = new Table({
    head: ["Image", "Title", "Id"],
    colWidths: [30, 80],
    wordWrap: true,
  });

  const rows = [];
  const row = [];

const body = await got(imageURL).buffer();
image = await terminalImage.buffer(body, {
     width: "20%",
     height: "20%",
});

row.push(image);
row.push("title");
row.push("id");

rows.push(row);

// Draw Table
table.push(...rows);
console.log(table.toString()); // <--- boom
speedytwenty commented 10 months ago

You are attempting to display a buffer within a cell when the cell contents should typically be a string or number.

row.push(image);

Try to convert that buffer to a string:

row.push(image.toString());
speedytwenty commented 10 months ago

Please reopen this issue if converting the buffer to a string doesn't resolve your issue.

ttessarolo commented 10 months ago

@speedytwenty it was the first attempt I did. In fact the image is a string. It doesn’t work.