Comparing version 1.0.2 to 1.0.3
@@ -29,2 +29,3 @@ #!/usr/bin/env node | ||
describe: 'Content for banner', | ||
coerce: str => str.replace(new RegExp('\\\\n', 'g'), '\n'), | ||
}); | ||
@@ -31,0 +32,0 @@ }) |
@@ -75,3 +75,4 @@ const chalk = require('chalk'); | ||
function printRow(str, width, paddingLength, color, border, borderColor) { | ||
const extraSpace = width - 2 - 2 * paddingLength - str.length; | ||
const borderLength = border.length; | ||
const extraSpace = width - 2 * (paddingLength + borderLength) - str.length; | ||
@@ -90,7 +91,14 @@ const leftSpacing = Math.floor(extraSpace / 2); | ||
function printContent(str, width, paddingLength, color, border, borderColor) { | ||
return wrap(str, { width: width - 2 * paddingLength }) | ||
function printContent(input, width, paddingLength, color, border, borderColor) { | ||
const borderLength = border.length; | ||
return input | ||
.split('\n') | ||
.map(s => s.trim()) | ||
.map(s => printRow(s, width, paddingLength, color, border, borderColor)) | ||
.map(str => | ||
wrap(str, { | ||
width: width - 2 * (paddingLength + borderLength), | ||
}).split('\n') | ||
) | ||
.reduce((output, strs) => output.concat(strs), []) | ||
.map(str => str.trim()) | ||
.map(str => printRow(str, width, paddingLength, color, border, borderColor)) | ||
.join('\n'); | ||
@@ -97,0 +105,0 @@ } |
@@ -14,2 +14,5 @@ const composeBanner = require('./index'); | ||
}); | ||
it('respects breaks', () => { | ||
expect(composeBanner('hello\nworld')).toMatchSnapshot(); | ||
}); | ||
}); |
{ | ||
"name": "cli-banner", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Create boxes around content", | ||
"license": "MIT", | ||
"engines": { | ||
"node": "^8.9.0", | ||
"yarn": "^1.3.2" | ||
"node": ">=6.0.0" | ||
}, | ||
@@ -10,0 +9,0 @@ "files": [ |
@@ -1,2 +0,2 @@ | ||
## CLI Box | ||
## CLI Banner | ||
@@ -3,0 +3,0 @@ Create boxes around strings - great for console printing |
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
13971
167