From 2d00338810f25cc5fd7fa1bdea3ff4983cb54ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Weslley=20Ara=C3=BAjo?= <46850407+wellwelwel@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:18:12 -0300 Subject: [PATCH] fix: prevent invalid column size count (#830) --- src/services/write.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/write.ts b/src/services/write.ts index 4ce9f8a5..6500e369 100644 --- a/src/services/write.ts +++ b/src/services/write.ts @@ -1,11 +1,13 @@ import type { Formatter } from '../services/format.js'; import { stdout } from 'node:process'; +const columns = Math.max((stdout.columns || 50) - 10, 40); + export const Write = { log: (data: string | Uint8Array | Formatter) => stdout.write(`${String(data)}\n`), hr: () => { - const line = '─'.repeat(stdout.columns - 10 || 40); + const line = '─'.repeat(columns); Write.log(`\n\x1b[2m\x1b[90m${line}\x1b[0m\n`); },