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

'box()' function does not work with a title >=2 chars longer than the content length #300

Open
GRyanParoz opened this issue Jun 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@GRyanParoz
Copy link

Environment

Consola version 3.2.3

Tested using Bun v1.1.12 and Node.js 18.20.3 (Stackblitz)

Reproduction

https://stackblitz.com/edit/stackblitz-starters-zlz8zk?file=index.js

Describe the bug

If the box function from consola/utils (or consola.box) is called with a "title" option that contains a string 2 characters longer than the content itself, an error is thrown and the box is not drawn.

Additional context

The error is coming from String.repeat, seemingly because the number of repeated characters is calculated by subtracting the title length from the content length or something similar.

Logs

RangeError: String.prototype.repeat argument must be greater than or equal to 0 and not be Infinity
      at repeat (:1:21)
      at box (<private-project>/node_modules/consola/dist/utils.mjs:246:18)
      at previewJson (<private-project>/src/logger.ts:17:13)
      at <private-project>/src/deploy-schema.ts:23:5

Bun v1.1.12 (Linux x64)
error: script "schema:deploy" exited with code 1

-----

Error: repeat count must be non-negative
    at _evaluate (https://stackblitzstarterszlz8zk-vfqw.w-corp-staticblitz.com/blitz.12d46890.js:40:783715)

Node.js 18.20.3
@pi0 pi0 added the bug Something isn't working label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants