@rushstack/terminal
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -106,14 +106,34 @@ "use strict"; | ||
const wrappedMessageLines = PrintUtilities.wrapWordsToLines(message, maxLineLength); | ||
// ╔═══════════╗ | ||
// ║ Message ║ | ||
// ╚═══════════╝ | ||
terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗ `); | ||
let longestLineLength = 0; | ||
const trimmedLines = []; | ||
for (const line of wrappedMessageLines) { | ||
const trimmedLine = line.trim(); | ||
const padding = boxWidth - trimmedLine.length - 2; | ||
const leftPadding = Math.floor(padding / 2); | ||
const rightPadding = padding - leftPadding; | ||
terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║ `); | ||
trimmedLines.push(trimmedLine); | ||
longestLineLength = Math.max(longestLineLength, trimmedLine.length); | ||
} | ||
terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝ `); | ||
if (longestLineLength > boxWidth - 2) { | ||
// If the longest line is longer than the box, print bars above and below the message | ||
// ═════════════ | ||
// Message | ||
// ═════════════ | ||
const headerAndFooter = ` ${'═'.repeat(boxWidth)}`; | ||
terminal.writeLine(headerAndFooter); | ||
for (const line of wrappedMessageLines) { | ||
terminal.writeLine(` ${line}`); | ||
} | ||
terminal.writeLine(headerAndFooter); | ||
} | ||
else { | ||
// ╔═══════════╗ | ||
// ║ Message ║ | ||
// ╚═══════════╝ | ||
terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗`); | ||
for (const trimmedLine of trimmedLines) { | ||
const padding = boxWidth - trimmedLine.length - 2; | ||
const leftPadding = Math.floor(padding / 2); | ||
const rightPadding = padding - leftPadding; | ||
terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║`); | ||
} | ||
terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝`); | ||
} | ||
} | ||
@@ -120,0 +140,0 @@ } |
{ | ||
"name": "@rushstack/terminal", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"description": "User interface primitives for console applications", | ||
@@ -14,7 +14,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@rushstack/node-core-library": "3.60.1" | ||
"@rushstack/node-core-library": "3.61.0" | ||
}, | ||
"devDependencies": { | ||
"colors": "~1.2.1", | ||
"@rushstack/heft": "0.62.0", | ||
"@rushstack/heft": "0.62.1", | ||
"local-node-rig": "1.0.0" | ||
@@ -21,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193403
2669
+ Added@rushstack/node-core-library@3.61.0(transitive)
- Removed@rushstack/node-core-library@3.60.1(transitive)