From 4ed86625045be3de2e3b471dbd9f81533f2c1dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=BChnel?= Date: Tue, 4 Oct 2016 23:33:36 +0200 Subject: [PATCH 1/4] Fix overflowing messages when using maxLength --- index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c67580c..a46007f 100644 --- a/index.js +++ b/index.js @@ -23,10 +23,14 @@ var defaultGreeting = '\n __' + chalk.yellow('\'.___.\'') + '__ ' + '\n ´ ' + chalk.red('` |') + '° ' + chalk.red('´ Y') + ' ` '; -// 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; +// Amount of characters of the yeoman character »column« → ` /___A___\ /` +var YEOMAN_CHARACTER_WIDTH = 17; + +// Amount of characters of the default top frame of the speech bubble → `╭──────────────────────────╮` +var DEFAULT_TOP_FRAME_WIDTH = 28; + +// Amount of characters of a total line +var TOTAL_CHARACTERS_PER_LINE = YEOMAN_CHARACTER_WIDTH + DEFAULT_TOP_FRAME_WIDTH; // The speech bubble will overflow the Yeoman character if the message is too long. var MAX_MESSAGE_LINES_BEFORE_OVERFLOW = 7; @@ -62,6 +66,7 @@ module.exports = function (message, options) { if (maxLength < options.maxLength) { maxLength = options.maxLength; + TOTAL_CHARACTERS_PER_LINE = maxLength + YEOMAN_CHARACTER_WIDTH + topOffset ; } } From 03a990aa5b7d62ef78bb38a4593c2062377ce293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Ku=CC=88hnel?= Date: Wed, 5 Oct 2016 21:06:53 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Fix=20problem=20with=20top=20offset=20and?= =?UTF-8?q?=20left=20padding=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … in case you use yosay repeatedly to generate multiple speech bubbles within one script. --- index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index a46007f..64ce8f3 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,6 @@ var repeating = require('repeating'); var cliBoxes = require('cli-boxes'); var border = cliBoxes.round; -var topOffset = 4; var leftOffset = 17; var defaultGreeting = '\n _-----_ ' + @@ -23,18 +22,6 @@ var defaultGreeting = '\n __' + chalk.yellow('\'.___.\'') + '__ ' + '\n ´ ' + chalk.red('` |') + '° ' + chalk.red('´ Y') + ' ` '; -// Amount of characters of the yeoman character »column« → ` /___A___\ /` -var YEOMAN_CHARACTER_WIDTH = 17; - -// Amount of characters of the default top frame of the speech bubble → `╭──────────────────────────╮` -var DEFAULT_TOP_FRAME_WIDTH = 28; - -// Amount of characters of a total line -var TOTAL_CHARACTERS_PER_LINE = YEOMAN_CHARACTER_WIDTH + DEFAULT_TOP_FRAME_WIDTH; - -// 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) { message = (message || 'Welcome to Yeoman, ladies and gentlemen!').trim(); options = options || {}; @@ -60,13 +47,26 @@ module.exports = function (message, options) { var styledIndexes = {}; var completedString = ''; var regExNewLine; + var topOffset = 4; + + // Amount of characters of the yeoman character »column« → ` /___A___\ /` + var YEOMAN_CHARACTER_WIDTH = 17; + + // Amount of characters of the default top frame of the speech bubble → `╭──────────────────────────╮` + var DEFAULT_TOP_FRAME_WIDTH = 28; + + // Amount of characters of a total line + var TOTAL_CHARACTERS_PER_LINE = YEOMAN_CHARACTER_WIDTH + DEFAULT_TOP_FRAME_WIDTH; + + // The speech bubble will overflow the Yeoman character if the message is too long. + var MAX_MESSAGE_LINES_BEFORE_OVERFLOW = 7; if (options.maxLength) { maxLength = stripAnsi(message).toLowerCase().split(' ').sort()[0].length; if (maxLength < options.maxLength) { maxLength = options.maxLength; - TOTAL_CHARACTERS_PER_LINE = maxLength + YEOMAN_CHARACTER_WIDTH + topOffset ; + TOTAL_CHARACTERS_PER_LINE = maxLength + YEOMAN_CHARACTER_WIDTH + topOffset; } } From d2b24f4afca37d0013c4feef88e9f71a6779e485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Ku=CC=88hnel?= Date: Wed, 5 Oct 2016 21:19:36 +0200 Subject: [PATCH 3/4] Update test fixtures --- test/fixture/ansi.json | 2 +- test/fixture/correctly-formatted-two-lines.json | 2 +- test/fixture/correctly-formatted.json | 2 +- test/fixture/half-ansi.json | 2 +- test/fixture/handle-fullwidth.json | 2 +- test/fixture/handle-new-line.json | 2 +- test/fixture/length-customization.json | 2 +- test/fixture/long-words.json | 2 +- test/fixture/overflow.json | 2 +- test/fixture/override-maxLength.json | 2 +- test/fixture/wrap-ansi-styles.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/fixture/ansi.json b/test/fixture/ansi.json index fc17d72..420ec36 100644 --- a/test/fixture/ansi.json +++ b/test/fixture/ansi.json @@ -1 +1 @@ -"╭──────────────────────────╮\n _-----_ \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m╰──────────────────────────╯\n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| ╭──────────────────────────╮\n `---------´ \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/correctly-formatted-two-lines.json b/test/fixture/correctly-formatted-two-lines.json index 19347d1..8bd5929 100644 --- a/test/fixture/correctly-formatted-two-lines.json +++ b/test/fixture/correctly-formatted-two-lines.json @@ -1 +1 @@ -"\n _-----_ ╭──────────────────────────╮\n | | \u001b[0m│\u001b[0m \u001b[0mWelcome to Yeoman,\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0mladies and gentlemen!\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m╰──────────────────────────╯\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | ╭──────────────────────────╮\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0mWelcome to Yeoman,\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0mladies and gentlemen!\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/correctly-formatted.json b/test/fixture/correctly-formatted.json index d70aaee..20e0ef6 100644 --- a/test/fixture/correctly-formatted.json +++ b/test/fixture/correctly-formatted.json @@ -1 +1 @@ -"\n _-----_ \n | | ╭──────────────────────────╮\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0mHi\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m╰──────────────────────────╯\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| ╭──────────────────────────╮\n `---------´ \u001b[0m│\u001b[0m \u001b[0mHi\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/half-ansi.json b/test/fixture/half-ansi.json index eff0371..e5d8a79 100644 --- a/test/fixture/half-ansi.json +++ b/test/fixture/half-ansi.json @@ -1 +1 @@ -"╭──────────────────────────╮\n _-----_ \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[49m\u001b[39m \u001b[49m\u001b[39mt\u001b[49m\u001b[39mh\u001b[49m\u001b[39me\u001b[49m\u001b[39mr\u001b[49m\u001b[39me\u001b[49m\u001b[39m,\u001b[49m\u001b[39m \u001b[49m\u001b[39ms\u001b[49m\u001b[39mi\u001b[49m\u001b[39mr\u001b[49m\u001b[39m!\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m╰──────────────────────────╯\n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| ╭──────────────────────────╮\n `---------´ \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[49m\u001b[39m \u001b[49m\u001b[39mt\u001b[49m\u001b[39mh\u001b[49m\u001b[39me\u001b[49m\u001b[39mr\u001b[49m\u001b[39me\u001b[49m\u001b[39m,\u001b[49m\u001b[39m \u001b[49m\u001b[39ms\u001b[49m\u001b[39mi\u001b[49m\u001b[39mr\u001b[49m\u001b[39m!\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/handle-fullwidth.json b/test/fixture/handle-fullwidth.json index 150acdb..ecfb298 100644 --- a/test/fixture/handle-fullwidth.json +++ b/test/fixture/handle-fullwidth.json @@ -1 +1 @@ -"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| ╭──────────────────────────╮\n `---------´ \u001b[0m│\u001b[0m \u001b[0m项目可以更新了\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/handle-new-line.json b/test/fixture/handle-new-line.json index 6bd443f..c7022d5 100644 --- a/test/fixture/handle-new-line.json +++ b/test/fixture/handle-new-line.json @@ -1 +1 @@ -" \u001b[0m│\u001b[0m \u001b[0m\u001b[0m \u001b[0m│\u001b[0m\n _-----_ \u001b[0m│\u001b[0m \u001b[0mfourth line\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m╰──────────────────────────╯\n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ ╭──────────────────────────╮\n | | \u001b[0m│\u001b[0m \u001b[0mfirst line\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0msecond line\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0m\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m│\u001b[0m \u001b[0mfourth line\u001b[0m \u001b[0m│\u001b[0m\n /___A___\\ /\u001b[0m╰──────────────────────────╯\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/length-customization.json b/test/fixture/length-customization.json index 69a4b05..72c1249 100644 --- a/test/fixture/length-customization.json +++ b/test/fixture/length-customization.json @@ -1 +1 @@ -"\n _-----_ ╭──────────╮\n | | \u001b[0m│\u001b[0m \u001b[0mHi\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m╰──────────╯\n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| ╭──────────╮\n `---------´ \u001b[0m│\u001b[0m \u001b[0mHi\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/long-words.json b/test/fixture/long-words.json index 4634027..067ca71 100644 --- a/test/fixture/long-words.json +++ b/test/fixture/long-words.json @@ -1 +1 @@ -" \u001b[0m╰──────────────────────────╯\n _-----_ \n | | \n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ ╭──────────────────────────╮\n | | \u001b[0m│\u001b[0m \u001b[0miloveunicornsiloveunicor\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0mnsiloveunicornsiloveunic\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0mornsiloveunicornsiloveun\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m│\u001b[0m \u001b[0micorns\u001b[0m \u001b[0m│\u001b[0m\n /___A___\\ /\u001b[0m╰──────────────────────────╯\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/overflow.json b/test/fixture/overflow.json index ad02ebe..5a8a7f6 100644 --- a/test/fixture/overflow.json +++ b/test/fixture/overflow.json @@ -1 +1 @@ -" \u001b[0m│\u001b[0m \u001b[0min owner’s\u001b[0m \u001b[0m│\u001b[0m\n \u001b[0m│\u001b[0m \u001b[0mface like\u001b[0m \u001b[0m│\u001b[0m\n \u001b[0m│\u001b[0m \u001b[0mcamera\u001b[0m \u001b[0m│\u001b[0m\n _-----_ \u001b[0m│\u001b[0m \u001b[0mlens. Cough\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m│\u001b[0m \u001b[0mfurball.\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m╰─────────────╯\n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n ╭─────────────╮\n \u001b[0m│\u001b[0m \u001b[0mLie on your\u001b[0m \u001b[0m│\u001b[0m\n _-----_ \u001b[0m│\u001b[0m \u001b[0mbelly and\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m│\u001b[0m \u001b[0mpurr when\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0myou are\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0masleep\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m│\u001b[0m \u001b[0mshove bum\u001b[0m \u001b[0m│\u001b[0m\n /___A___\\ /\u001b[0m│\u001b[0m \u001b[0min owner’s\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m| ~ |\u001b[39m \u001b[0m│\u001b[0m \u001b[0mface like\u001b[0m \u001b[0m│\u001b[0m\n __\u001b[33m'.___.'\u001b[39m__ \u001b[0m│\u001b[0m \u001b[0mcamera\u001b[0m \u001b[0m│\u001b[0m\n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \u001b[0m│\u001b[0m \u001b[0mlens. Cough\u001b[0m \u001b[0m│\u001b[0m\n \u001b[0m│\u001b[0m \u001b[0mfurball.\u001b[0m \u001b[0m│\u001b[0m\n \u001b[0m╰─────────────╯\n" \ No newline at end of file diff --git a/test/fixture/override-maxLength.json b/test/fixture/override-maxLength.json index 4647fd6..09c046d 100644 --- a/test/fixture/override-maxLength.json +++ b/test/fixture/override-maxLength.json @@ -1 +1 @@ -"╭────────╮\n _-----_ \u001b[0m│\u001b[0m \u001b[0mHello,\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m│\u001b[0m \u001b[0mbuddy!\u001b[0m \u001b[0m│\u001b[0m\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m╰────────╯\n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | ╭────────╮\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0mHello,\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0mbuddy!\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file diff --git a/test/fixture/wrap-ansi-styles.json b/test/fixture/wrap-ansi-styles.json index 6170120..4071ecc 100644 --- a/test/fixture/wrap-ansi-styles.json +++ b/test/fixture/wrap-ansi-styles.json @@ -1 +1 @@ -" \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[49m\u001b[39m \u001b[49m\u001b[39mt\u001b[49m\u001b[39mh\u001b[49m\u001b[39me\u001b[49m\u001b[39mr\u001b[49m\u001b[39me\u001b[49m\u001b[39m,\u001b[49m\u001b[39m \u001b[49m\u001b[39ms\u001b[49m\u001b[39mi\u001b[49m\u001b[39mr\u001b[49m\u001b[39m!\u001b[49m\u001b[39m \u001b[44m\u001b[37my\u001b[44m\u001b[37mo\u001b[44m\u001b[37mu\u001b[44m\u001b[37m \u001b[44m\u001b[37ma\u001b[44m\u001b[37mr\u001b[44m\u001b[37me\u001b[0m \u001b[0m│\u001b[0m\n _-----_ \u001b[0m│\u001b[0m \u001b[0m\u001b[44m\u001b[37ml\u001b[44m\u001b[37mo\u001b[44m\u001b[37mo\u001b[44m\u001b[37mk\u001b[44m\u001b[37mi\u001b[44m\u001b[37mn\u001b[44m\u001b[37mg\u001b[39m\u001b[49m \u001b[39m\u001b[49ms\u001b[39m\u001b[49mw\u001b[39m\u001b[49me\u001b[39m\u001b[49ml\u001b[39m\u001b[49ml\u001b[39m\u001b[49m \u001b[39m\u001b[49mt\u001b[39m\u001b[49mo\u001b[39m\u001b[49md\u001b[39m\u001b[49ma\u001b[39m\u001b[49my\u001b[39m\u001b[49m!\u001b[0m \u001b[0m│\u001b[0m\n | | \u001b[0m╰──────────────────────────╯\n |\u001b[31m--(o)--\u001b[39m| \n `---------´ \n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file +"\n _-----_ \n | | ╭──────────────────────────╮\n |\u001b[31m--(o)--\u001b[39m| \u001b[0m│\u001b[0m \u001b[0m\u001b[31m\u001b[47mH\u001b[31m\u001b[47mi\u001b[49m\u001b[39m \u001b[49m\u001b[39mt\u001b[49m\u001b[39mh\u001b[49m\u001b[39me\u001b[49m\u001b[39mr\u001b[49m\u001b[39me\u001b[49m\u001b[39m,\u001b[49m\u001b[39m \u001b[49m\u001b[39ms\u001b[49m\u001b[39mi\u001b[49m\u001b[39mr\u001b[49m\u001b[39m!\u001b[49m\u001b[39m \u001b[44m\u001b[37my\u001b[44m\u001b[37mo\u001b[44m\u001b[37mu\u001b[44m\u001b[37m \u001b[44m\u001b[37ma\u001b[44m\u001b[37mr\u001b[44m\u001b[37me\u001b[0m \u001b[0m│\u001b[0m\n `---------´ \u001b[0m│\u001b[0m \u001b[0m\u001b[44m\u001b[37ml\u001b[44m\u001b[37mo\u001b[44m\u001b[37mo\u001b[44m\u001b[37mk\u001b[44m\u001b[37mi\u001b[44m\u001b[37mn\u001b[44m\u001b[37mg\u001b[39m\u001b[49m \u001b[39m\u001b[49ms\u001b[39m\u001b[49mw\u001b[39m\u001b[49me\u001b[39m\u001b[49ml\u001b[39m\u001b[49ml\u001b[39m\u001b[49m \u001b[39m\u001b[49mt\u001b[39m\u001b[49mo\u001b[39m\u001b[49md\u001b[39m\u001b[49ma\u001b[39m\u001b[49my\u001b[39m\u001b[49m!\u001b[0m \u001b[0m│\u001b[0m\n \u001b[33m(\u001b[39m _\u001b[33m´U`\u001b[39m_ \u001b[33m)\u001b[39m \u001b[0m╰──────────────────────────╯\n /___A___\\ /\n \u001b[33m| ~ |\u001b[39m \n __\u001b[33m'.___.'\u001b[39m__ \n ´ \u001b[31m` |\u001b[39m° \u001b[31m´ Y\u001b[39m ` \n" \ No newline at end of file From 27a96b4ac308dbaf33d4405c2779d54e0be32ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Ku=CC=88hnel?= Date: Thu, 6 Oct 2016 10:44:51 +0200 Subject: [PATCH 4/4] Add manual test file. --- test/manual-test.js | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/manual-test.js diff --git a/test/manual-test.js b/test/manual-test.js new file mode 100644 index 0000000..451d41f --- /dev/null +++ b/test/manual-test.js @@ -0,0 +1,56 @@ +'use strict'; + +const chalk = require('chalk'); +const yosay = require('../index.js'); + +/* + * Yo. Fire this file locally with `node test/manual-test.js` at least after you + * have newly generated the text fixtures to double check that all available + * option have a correct looking output. + * Thanks (ᵔᴥᵔ) + */ + +console.log(yosay('Hello, and welcome to my fantastic generator full of whimsy and bubble gum!')); + +console.log(yosay('Hi')); + +console.log(yosay('Welcome to Yeoman, ladies and gentlemen!')); + +console.log(yosay('Hi', {maxLength: 8})); + +console.log(yosay('Hello, buddy!', {maxLength: 4})); + +console.log(yosay(chalk.red.bgWhite('Hi'))); + +console.log(yosay(chalk.red.bgWhite('Hi') + ' there, sir!')); + +console.log(yosay(chalk.red.bgWhite('Hi') + ' there, sir! ' + chalk.bgBlue.white('you are looking') + ' swell today!')); + +console.log(yosay('first line\nsecond line\n\nfourth line')); + +console.log(yosay('项目可以更新了')); + +console.log(yosay('iloveunicornsiloveunicornsiloveunicornsiloveunicornsiloveunicornsiloveunicorns')); + +console.log(yosay('Lie on your belly and purr when you are asleep shove bum in owner’s face like camera lens. Cough furball.', {maxLength: 11})); +console.log(yosay('Lie on your belly and purr when you are asleep shove bum in owner’s face like camera lens. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball.')); +console.log(yosay('Lie on your belly and purr when you are asleep shove bum in owner’s face like camera lens. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball.', {maxLength: 11})); +console.log(yosay('Lie on your belly and purr when you are asleep shove bum in owner’s face like camera lens. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball. Cough furball.', {maxLength: 26})); + +console.log(yosay( + 'That’s it. Feel free to fire up the server with ' + + chalk.green('`npm run start:dev`') + + 'or use our subgenerator to create endpoints.' +)); + +console.log(yosay('That’s it. Feel free to fire up the server with `npm run start:dev` or use our subgenerator to create endpoints.')); + +console.log(yosay( + 'That’s it. Feel free to fire up the server with ' + + chalk.green('`npm run start:dev`') + '.' +)); + +console.log(yosay( + 'That’s it. Feel free to fire up the server with ' + + '`npm run start:dev`.' +));