Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Invalid count value when no rows #415

Closed
jarrodek opened this issue Feb 12, 2022 · 5 comments · Fixed by #422
Closed

Error: Invalid count value when no rows #415

jarrodek opened this issue Feb 12, 2022 · 5 comments · Fixed by #422
Labels

Comments

@jarrodek
Copy link

The following code fails with the Invalid count value when no rows error.

import { printTable, Table } from 'console-table-printer';

const table = new Table({
  title: 'Project folders',
});
table.printTable();

It looks like the textWithPadding() function in the string-utils file does not handle situation when the size is invalid.

The use case is to print the table header even when there are no items to render.

@ayonious
Copy link
Owner

@jarrodek what is your expected output for this?
Why do you want to print only table header?

@jarrodek
Copy link
Author

Essentially yes. The command in my CLI I am building may not return any results (for example when a query yields no results). The command's output is still the same which is the table but in this specific case, it has no rows. This way the interface stays consistent regardless of the result.

@Dirrk
Copy link
Contributor

Dirrk commented May 6, 2022

This also fails when the title length > column length.

This works because the title is short

const t = new Table({ title: 'Short'}, columns: ['test'], ['example']);
t.addRow({ test: 1, example: 2 });
t.printTable();

This fails due to the title being longer than the columns

new Table({ title: 'Really long title that is longer than the table itself'}, columns: ['test'], ['example']);
t.addRow({ test: 1, example: 2 });
t.printTable();

@ayonious
Copy link
Owner

🎉 This issue has been resolved in version 2.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ayonious
Copy link
Owner

ayonious commented Jul 2, 2023

Seems already been resolved

@ayonious ayonious closed this as completed Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants