diff --git a/index.js b/index.js index c67580c..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,14 +22,6 @@ 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; - -// 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 || {}; @@ -56,12 +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; } } 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 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`.' +));