Comparing version 1.1.1 to 1.2.0
47
index.js
@@ -10,7 +10,9 @@ 'use strict'; | ||
var repeating = require('repeating'); | ||
var cliBoxes = require('cli-boxes'); | ||
var topOffset = 3; | ||
var border = cliBoxes.round; | ||
var topOffset = 4; | ||
var leftOffset = 17; | ||
var defaultGreeting = | ||
'\n _-----_' + | ||
'\n _-----_ ' + | ||
'\n | | ' + | ||
@@ -20,3 +22,3 @@ '\n |' + chalk.red('--(o)--') + '| ' + | ||
'\n ' + chalk.yellow('(') + ' _' + chalk.yellow('ยดU`') + '_ ' + chalk.yellow(')') + ' ' + | ||
'\n /___A___\\ ' + | ||
'\n /___A___\\ /' + | ||
'\n ' + chalk.yellow('| ~ |') + ' ' + | ||
@@ -26,2 +28,10 @@ '\n __' + chalk.yellow('\'.___.\'') + '__ ' + | ||
// A total line with 45 characters consists of: | ||
// 28 chars for the top frame of the speech bubble โ `โญโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ` | ||
// 17 chars for the yeoman character ยปcolumnยซ โ ` /___A___\ /` | ||
var TOTAL_CHARACTERS_PER_LINE = 45; | ||
// The speech bubble will overflow the Yeoman character if the message is too long. | ||
var MAX_MESSAGE_LINES_BEFORE_OVERFLOW = 7; | ||
module.exports = function (message, options) { | ||
@@ -63,6 +73,8 @@ message = (message || 'Welcome to Yeoman, ladies and gentlemen!').trim(); | ||
var borderHorizontal = repeating(border.horizontal, maxLength + 2); | ||
frame = { | ||
top: '.' + repeating('-', maxLength + 2) + '.', | ||
side: ansiStyles.reset.open + '|' + ansiStyles.reset.open, | ||
bottom: ansiStyles.reset.open + '\'' + repeating('-', maxLength + 2) + '\'' | ||
top: border.topLeft + borderHorizontal + border.topRight, | ||
side: ansiStyles.reset.open + border.vertical + ansiStyles.reset.open, | ||
bottom: ansiStyles.reset.open + border.bottomLeft + borderHorizontal + border.bottomRight | ||
}; | ||
@@ -128,2 +140,25 @@ | ||
if (index === 0) { | ||
// Need to adjust the top position of the speech bubble depending on the | ||
// amount of lines of the message. | ||
if (array.length === 2) { | ||
topOffset -= 1; | ||
} | ||
if (array.length >= 3) { | ||
topOffset -= 2; | ||
} | ||
// The speech bubble will overflow the Yeoman character if the message | ||
// is too long. So we vertically center the bubble by adding empty lines | ||
// on top of the greeting. | ||
if (array.length > MAX_MESSAGE_LINES_BEFORE_OVERFLOW) { | ||
var emptyLines = Math.ceil((array.length - MAX_MESSAGE_LINES_BEFORE_OVERFLOW) / 2); | ||
for (var i = 0; i < emptyLines; i++) { | ||
greeting.unshift(''); | ||
} | ||
frame.top = pad.left(frame.top, TOTAL_CHARACTERS_PER_LINE); | ||
} | ||
greeting[topOffset - 1] += frame.top; | ||
@@ -130,0 +165,0 @@ } |
{ | ||
"name": "yosay", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Tell Yeoman what to say", | ||
@@ -36,2 +36,3 @@ "license": "BSD-2-Clause", | ||
"chalk": "^1.0.0", | ||
"cli-boxes": "^1.0.0", | ||
"pad-component": "0.0.1", | ||
@@ -38,0 +39,0 @@ "repeating": "^2.0.0", |
@@ -25,9 +25,9 @@ # yosay [![Build Status](https://travis-ci.org/yeoman/yosay.svg?branch=master)](https://travis-ci.org/yeoman/yosay) | ||
/* | ||
_-----_ | ||
| | .--------------------------. | ||
|--(o)--| | Hello, and welcome to my | | ||
`---------ยด | fantastic generator full | | ||
( _ยดU`_ ) | of whimsy and bubble | | ||
/___A___\ | gum! | | ||
| ~ | '--------------------------' | ||
_-----_ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
| | โ Hello, and welcome to my โ | ||
|--(o)--| โ fantastic generator full โ | ||
`---------ยด โ of whimsy and bubble โ | ||
( _ยดU`_ ) โ gum! โ | ||
/___A___\ /โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
| ~ | | ||
__'.___.'__ | ||
@@ -59,7 +59,7 @@ ยด ` |ยฐ ยด Y ` | ||
_-----_ | ||
| | .--------------------------. | ||
|--(o)--| | Sindre is a horse | | ||
`---------ยด '--------------------------' | ||
( _ยดU`_ ) | ||
/___A___\ | ||
| | | ||
|--(o)--| โญโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
`---------ยด โ Sindre is a horse โ | ||
( _ยดU`_ ) โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
/___A___\ / | ||
| ~ | | ||
@@ -66,0 +66,0 @@ __'.___.'__ |
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
8879
168
10
+ Addedcli-boxes@^1.0.0
+ Addedcli-boxes@1.0.0(transitive)