Skip to content

Commit

Permalink
fix: prevent invalid column size count (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel authored Oct 27, 2024
1 parent 08f7867 commit 2d00338
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/write.ts
Original file line number Diff line number Diff line change
@@ -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`);
},
Expand Down

0 comments on commit 2d00338

Please sign in to comment.