pax_global_header00006660000000000000000000000064144507772600014526gustar00rootroot0000000000000052 comment=bbebe45d9aa8f2fd63448150b1ce804ce926e5a6 boxen-7.1.1/000077500000000000000000000000001445077726000126475ustar00rootroot00000000000000boxen-7.1.1/.editorconfig000066400000000000000000000002571445077726000153300ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 boxen-7.1.1/.gitattributes000066400000000000000000000000231445077726000155350ustar00rootroot00000000000000* text=auto eol=lf boxen-7.1.1/.github/000077500000000000000000000000001445077726000142075ustar00rootroot00000000000000boxen-7.1.1/.github/funding.yml000066400000000000000000000001571445077726000163670ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/boxen custom: https://sindresorhus.com/donate boxen-7.1.1/.github/security.md000066400000000000000000000002631445077726000164010ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. boxen-7.1.1/.github/workflows/000077500000000000000000000000001445077726000162445ustar00rootroot00000000000000boxen-7.1.1/.github/workflows/main.yml000066400000000000000000000010361445077726000177130ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 18 - 16 - 14 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install - shell: 'script -q -e -c "bash {0}"' # Workaround for https://github.com/actions/runner/issues/241 run: npm test boxen-7.1.1/.gitignore000066400000000000000000000000431445077726000146340ustar00rootroot00000000000000node_modules yarn.lock .nyc_output boxen-7.1.1/.npmrc000066400000000000000000000000231445077726000137620ustar00rootroot00000000000000package-lock=false boxen-7.1.1/example.js000066400000000000000000000045721445077726000146500ustar00rootroot00000000000000import process from 'node:process'; import chalk from 'chalk'; import boxen from './index.js'; console.log('\n\n' + boxen(chalk.cyan('unicorn'), { padding: 1, margin: 1, borderColor: 'yellow', }) + '\n'); console.log('\n\n' + boxen(chalk.cyan('unicorn'), { padding: 1, margin: 1, borderColor: 'yellow', borderStyle: 'double', }) + '\n'); console.log('\n\n' + boxen(chalk.cyan('unicorn'), { padding: 1, margin: 1, borderColor: '#eebbaa', borderStyle: 'double', }) + '\n'); console.log('\n\n' + boxen(chalk.black('unicorn'), { padding: 1, margin: 1, borderColor: '#ffc0cb', backgroundColor: '#00ffff', borderStyle: 'double', }) + '\n'); console.log('\n\n' + boxen(chalk.black('unicorn'), { padding: 1, margin: 1, borderColor: 'yellow', backgroundColor: 'magenta', borderStyle: { topLeft: '+', topRight: '+', bottomLeft: '+', bottomRight: '+', top: '-', bottom: '-', left: '|', right: '|', }, }) + '\n'); const sentences = 'Unbreakable_text_because_it_has_no_spaces '.repeat(5); console.log('\n\n' + boxen(sentences, {textAlignment: 'left'}) + '\n'); console.log('\n\n' + boxen(sentences, {textAlignment: 'center'}) + '\n'); console.log('\n\n' + boxen(sentences, {textAlignment: 'right', padding: {left: 1, right: 1, top: 0, bottom: 0}}) + '\n'); const longWord = 'x'.repeat(process.stdout.columns + 20); console.log('\n\n' + boxen(longWord, {textAlignment: 'center'}) + '\n'); const title = 'Beautiful title'; console.log('\n\n' + boxen('This box has a nice title', {title}) + '\n'); console.log('\n\n' + boxen('This box has a centered title', {title, titleAlignment: 'center'}) + '\n'); console.log('\n\n' + boxen('This box has fixed width of 20', {width: 20}) + '\n'); console.log('\n\n' + boxen('This box has fixed width of 50', {width: 50}) + '\n'); console.log('\n\n' + boxen('This box has fixed height of 5', {height: 5}) + '\n'); console.log('\n\n' + boxen('This box has fixed height of 5', {height: 5, padding: 2}) + '\n'); console.log('\n\n' + boxen('This box has fixed height of 5 and width of 15', {height: 8, width: 15}) + '\n'); console.log('\n\n' + boxen('This box is in fullscreen !', {fullscreen: true}) + '\n'); console.log('\n\n' + boxen('This box is in full-width and half-height !', {fullscreen: (w, h) => [w, h / 2]}) + '\n'); console.log('\n\n' + boxen('And this one is in half-width and full-height !', {fullscreen: (w, h) => [w / 2, h]}) + '\n'); boxen-7.1.1/index.d.ts000066400000000000000000000115701445077726000145540ustar00rootroot00000000000000import {type LiteralUnion} from 'type-fest'; import {type BoxStyle, type Boxes as CLIBoxes} from 'cli-boxes'; /** All box styles. */ type Boxes = { readonly none: BoxStyle; } & CLIBoxes; /** Characters used for custom border. @example ``` // attttb // l r // dbbbbc const border: CustomBorderStyle = { topLeft: 'a', topRight: 'b', bottomRight: 'c', bottomLeft: 'd', left: 'l', right: 'r', top: 't', bottom: 'b', }; ``` */ export type CustomBorderStyle = { /** @deprecated Use `top` and `bottom` instead. */ horizontal?: string; /** @deprecated Use `left` and `right` instead. */ vertical?: string; } & BoxStyle; /** Spacing used for `padding` and `margin`. */ export type Spacing = { readonly top?: number; readonly right?: number; readonly bottom?: number; readonly left?: number; }; export type Options = { /** Color of the box border. */ readonly borderColor?: LiteralUnion< | 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'grey' | 'blackBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright', string >; /** Style of the box border. @default 'single' */ readonly borderStyle?: keyof Boxes | CustomBorderStyle; /** Reduce opacity of the border. @default false */ readonly dimBorder?: boolean; /** Space between the text and box border. @default 0 */ readonly padding?: number | Spacing; /** Space around the box. @default 0 */ readonly margin?: number | Spacing; /** Float the box on the available terminal screen space. @default 'left' */ readonly float?: 'left' | 'right' | 'center'; /** Color of the background. */ readonly backgroundColor?: LiteralUnion< | 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'blackBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright', string >; /** Align the text in the box based on the widest line. @default 'left' @deprecated Use `textAlignment` instead. */ readonly align?: 'left' | 'right' | 'center'; /** Align the text in the box based on the widest line. @default 'left' */ readonly textAlignment?: 'left' | 'right' | 'center'; /** Display a title at the top of the box. If needed, the box will horizontally expand to fit the title. @example ``` console.log(boxen('foo bar', {title: 'example'})); // ┌ example ┐ // │foo bar │ // └─────────┘ ``` */ readonly title?: string; /** Align the title in the top bar. @default 'left' @example ``` console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'center'})); // ┌─── example ───┐ // │foo bar foo bar│ // └───────────────┘ console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'right'})); // ┌────── example ┐ // │foo bar foo bar│ // └───────────────┘ ``` */ readonly titleAlignment?: 'left' | 'right' | 'center'; /** Set a fixed width for the box. __Note__: This disables terminal overflow handling and may cause the box to look broken if the user's terminal is not wide enough. @example ``` import boxen from 'boxen'; console.log(boxen('foo bar', {width: 15})); // ┌─────────────┐ // │foo bar │ // └─────────────┘ ``` */ readonly width?: number; /** Set a fixed height for the box. __Note__: This option will crop overflowing content. @example ``` import boxen from 'boxen'; console.log(boxen('foo bar', {height: 5})); // ┌───────┐ // │foo bar│ // │ │ // │ │ // └───────┘ ``` */ readonly height?: number; /** __boolean__: Whether or not to fit all available space within the terminal. __function__: Pass a callback function to control box dimensions. @example ``` import boxen from 'boxen'; console.log(boxen('foo bar', { fullscreen: (width, height) => [width, height - 1], })); ``` */ readonly fullscreen?: boolean | ((width: number, height: number) => [width: number, height: number]); }; /** Creates a box in the terminal. @param text - The text inside the box. @returns The box. @example ``` import boxen from 'boxen'; console.log(boxen('unicorn', {padding: 1})); // ┌─────────────┐ // │ │ // │ unicorn │ // │ │ // └─────────────┘ console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'})); // // ╔═════════════╗ // ║ ║ // ║ unicorn ║ // ║ ║ // ╚═════════════╝ // ``` */ export default function boxen(text: string, options?: Options): string; boxen-7.1.1/index.js000066400000000000000000000261261445077726000143230ustar00rootroot00000000000000import process from 'node:process'; import stringWidth from 'string-width'; import chalk from 'chalk'; import widestLine from 'widest-line'; import cliBoxes from 'cli-boxes'; import camelCase from 'camelcase'; import ansiAlign from 'ansi-align'; import wrapAnsi from 'wrap-ansi'; const NEWLINE = '\n'; const PAD = ' '; const NONE = 'none'; const terminalColumns = () => { const {env, stdout, stderr} = process; if (stdout?.columns) { return stdout.columns; } if (stderr?.columns) { return stderr.columns; } if (env.COLUMNS) { return Number.parseInt(env.COLUMNS, 10); } return 80; }; const getObject = detail => typeof detail === 'number' ? { top: detail, right: detail * 3, bottom: detail, left: detail * 3, } : { top: 0, right: 0, bottom: 0, left: 0, ...detail, }; const getBorderWidth = borderStyle => borderStyle === NONE ? 0 : 2; const getBorderChars = borderStyle => { const sides = [ 'topLeft', 'topRight', 'bottomRight', 'bottomLeft', 'left', 'right', 'top', 'bottom', ]; let characters; // Create empty border style if (borderStyle === NONE) { borderStyle = {}; for (const side of sides) { borderStyle[side] = ''; } } if (typeof borderStyle === 'string') { characters = cliBoxes[borderStyle]; if (!characters) { throw new TypeError(`Invalid border style: ${borderStyle}`); } } else { // Ensure retro-compatibility if (typeof borderStyle?.vertical === 'string') { borderStyle.left = borderStyle.vertical; borderStyle.right = borderStyle.vertical; } // Ensure retro-compatibility if (typeof borderStyle?.horizontal === 'string') { borderStyle.top = borderStyle.horizontal; borderStyle.bottom = borderStyle.horizontal; } for (const side of sides) { if (borderStyle[side] === null || typeof borderStyle[side] !== 'string') { throw new TypeError(`Invalid border style: ${side}`); } } characters = borderStyle; } return characters; }; const makeTitle = (text, horizontal, alignment) => { let title = ''; const textWidth = stringWidth(text); switch (alignment) { case 'left': { title = text + horizontal.slice(textWidth); break; } case 'right': { title = horizontal.slice(textWidth) + text; break; } default: { horizontal = horizontal.slice(textWidth); if (horizontal.length % 2 === 1) { // This is needed in case the length is odd horizontal = horizontal.slice(Math.floor(horizontal.length / 2)); title = horizontal.slice(1) + text + horizontal; // We reduce the left part of one character to avoid the bar to go beyond its limit } else { horizontal = horizontal.slice(horizontal.length / 2); title = horizontal + text + horizontal; } break; } } return title; }; const makeContentText = (text, {padding, width, textAlignment, height}) => { text = ansiAlign(text, {align: textAlignment}); let lines = text.split(NEWLINE); const textWidth = widestLine(text); const max = width - padding.left - padding.right; if (textWidth > max) { const newLines = []; for (const line of lines) { const createdLines = wrapAnsi(line, max, {hard: true}); const alignedLines = ansiAlign(createdLines, {align: textAlignment}); const alignedLinesArray = alignedLines.split('\n'); const longestLength = Math.max(...alignedLinesArray.map(s => stringWidth(s))); for (const alignedLine of alignedLinesArray) { let paddedLine; switch (textAlignment) { case 'center': { paddedLine = PAD.repeat((max - longestLength) / 2) + alignedLine; break; } case 'right': { paddedLine = PAD.repeat(max - longestLength) + alignedLine; break; } default: { paddedLine = alignedLine; break; } } newLines.push(paddedLine); } } lines = newLines; } if (textAlignment === 'center' && textWidth < max) { lines = lines.map(line => PAD.repeat((max - textWidth) / 2) + line); } else if (textAlignment === 'right' && textWidth < max) { lines = lines.map(line => PAD.repeat(max - textWidth) + line); } const paddingLeft = PAD.repeat(padding.left); const paddingRight = PAD.repeat(padding.right); lines = lines.map(line => paddingLeft + line + paddingRight); lines = lines.map(line => { if (width - stringWidth(line) > 0) { switch (textAlignment) { case 'center': { return line + PAD.repeat(width - stringWidth(line)); } case 'right': { return line + PAD.repeat(width - stringWidth(line)); } default: { return line + PAD.repeat(width - stringWidth(line)); } } } return line; }); if (padding.top > 0) { lines = [...Array.from({length: padding.top}).fill(PAD.repeat(width)), ...lines]; } if (padding.bottom > 0) { lines = [...lines, ...Array.from({length: padding.bottom}).fill(PAD.repeat(width))]; } if (height && lines.length > height) { lines = lines.slice(0, height); } else if (height && lines.length < height) { lines = [...lines, ...Array.from({length: height - lines.length}).fill(PAD.repeat(width))]; } return lines.join(NEWLINE); }; const boxContent = (content, contentWidth, options) => { const colorizeBorder = border => { const newBorder = options.borderColor ? getColorFn(options.borderColor)(border) : border; return options.dimBorder ? chalk.dim(newBorder) : newBorder; }; const colorizeContent = content => options.backgroundColor ? getBGColorFn(options.backgroundColor)(content) : content; const chars = getBorderChars(options.borderStyle); const columns = terminalColumns(); let marginLeft = PAD.repeat(options.margin.left); if (options.float === 'center') { const marginWidth = Math.max((columns - contentWidth - getBorderWidth(options.borderStyle)) / 2, 0); marginLeft = PAD.repeat(marginWidth); } else if (options.float === 'right') { const marginWidth = Math.max(columns - contentWidth - options.margin.right - getBorderWidth(options.borderStyle), 0); marginLeft = PAD.repeat(marginWidth); } let result = ''; if (options.margin.top) { result += NEWLINE.repeat(options.margin.top); } if (options.borderStyle !== NONE || options.title) { result += colorizeBorder(marginLeft + chars.topLeft + (options.title ? makeTitle(options.title, chars.top.repeat(contentWidth), options.titleAlignment) : chars.top.repeat(contentWidth)) + chars.topRight) + NEWLINE; } const lines = content.split(NEWLINE); result += lines.map(line => marginLeft + colorizeBorder(chars.left) + colorizeContent(line) + colorizeBorder(chars.right)).join(NEWLINE); if (options.borderStyle !== NONE) { result += NEWLINE + colorizeBorder(marginLeft + chars.bottomLeft + chars.bottom.repeat(contentWidth) + chars.bottomRight); } if (options.margin.bottom) { result += NEWLINE.repeat(options.margin.bottom); } return result; }; const sanitizeOptions = options => { // If fullscreen is enabled, max-out unspecified width/height if (options.fullscreen && process?.stdout) { let newDimensions = [process.stdout.columns, process.stdout.rows]; if (typeof options.fullscreen === 'function') { newDimensions = options.fullscreen(...newDimensions); } if (!options.width) { options.width = newDimensions[0]; } if (!options.height) { options.height = newDimensions[1]; } } // If width is provided, make sure it's not below 1 if (options.width) { options.width = Math.max(1, options.width - getBorderWidth(options.borderStyle)); } // If height is provided, make sure it's not below 1 if (options.height) { options.height = Math.max(1, options.height - getBorderWidth(options.borderStyle)); } return options; }; const formatTitle = (title, borderStyle) => borderStyle === NONE ? title : ` ${title} `; const determineDimensions = (text, options) => { options = sanitizeOptions(options); const widthOverride = options.width !== undefined; const columns = terminalColumns(); const borderWidth = getBorderWidth(options.borderStyle); const maxWidth = columns - options.margin.left - options.margin.right - borderWidth; const widest = widestLine(wrapAnsi(text, columns - borderWidth, {hard: true, trim: false})) + options.padding.left + options.padding.right; // If title and width are provided, title adheres to fixed width if (options.title && widthOverride) { options.title = options.title.slice(0, Math.max(0, options.width - 2)); if (options.title) { options.title = formatTitle(options.title, options.borderStyle); } } else if (options.title) { options.title = options.title.slice(0, Math.max(0, maxWidth - 2)); // Recheck if title isn't empty now if (options.title) { options.title = formatTitle(options.title, options.borderStyle); // If the title is larger than content, box adheres to title width if (stringWidth(options.title) > widest) { options.width = stringWidth(options.title); } } } // If fixed width is provided, use it or content width as reference options.width = options.width ? options.width : widest; if (!widthOverride) { if ((options.margin.left && options.margin.right) && options.width > maxWidth) { // Let's assume we have margins: left = 3, right = 5, in total = 8 const spaceForMargins = columns - options.width - borderWidth; // Let's assume we have space = 4 const multiplier = spaceForMargins / (options.margin.left + options.margin.right); // Here: multiplier = 4/8 = 0.5 options.margin.left = Math.max(0, Math.floor(options.margin.left * multiplier)); options.margin.right = Math.max(0, Math.floor(options.margin.right * multiplier)); // Left: 3 * 0.5 = 1.5 -> 1 // Right: 6 * 0.5 = 3 } // Re-cap width considering the margins after shrinking options.width = Math.min(options.width, columns - borderWidth - options.margin.left - options.margin.right); } // Prevent padding overflow if (options.width - (options.padding.left + options.padding.right) <= 0) { options.padding.left = 0; options.padding.right = 0; } if (options.height && options.height - (options.padding.top + options.padding.bottom) <= 0) { options.padding.top = 0; options.padding.bottom = 0; } return options; }; const isHex = color => color.match(/^#(?:[0-f]{3}){1,2}$/i); const isColorValid = color => typeof color === 'string' && (chalk[color] ?? isHex(color)); const getColorFn = color => isHex(color) ? chalk.hex(color) : chalk[color]; const getBGColorFn = color => isHex(color) ? chalk.bgHex(color) : chalk[camelCase(['bg', color])]; export default function boxen(text, options) { options = { padding: 0, borderStyle: 'single', dimBorder: false, textAlignment: 'left', float: 'left', titleAlignment: 'left', ...options, }; // This option is deprecated if (options.align) { options.textAlignment = options.align; } if (options.borderColor && !isColorValid(options.borderColor)) { throw new Error(`${options.borderColor} is not a valid borderColor`); } if (options.backgroundColor && !isColorValid(options.backgroundColor)) { throw new Error(`${options.backgroundColor} is not a valid backgroundColor`); } options.padding = getObject(options.padding); options.margin = getObject(options.margin); options = determineDimensions(text, options); text = makeContentText(text, options); return boxContent(text, options.width, options); } export {default as _borderStyles} from 'cli-boxes'; boxen-7.1.1/index.test-d.ts000066400000000000000000000026771445077726000155410ustar00rootroot00000000000000import {expectType} from 'tsd'; import boxen, {type Spacing, type CustomBorderStyle} from './index.js'; const border: CustomBorderStyle = { topLeft: ' ', topRight: ' ', bottomLeft: ' ', bottomRight: ' ', top: ' ', bottom: ' ', left: ' ', right: ' ', }; const spacing: Spacing = { top: 1, right: 0, bottom: 1, left: 0, }; expectType(boxen('unicorns')); expectType(boxen('unicorns', {title: 'title'})); expectType(boxen('unicorns', {title: 'title', titleAlignment: 'center'})); expectType(boxen('unicorns', {borderColor: 'green'})); expectType(boxen('unicorns', {borderColor: '#ff0000'})); expectType(boxen('unicorns', {borderStyle: 'double'})); expectType(boxen('unicorns', {borderStyle: border})); expectType(boxen('unicorns', {dimBorder: true})); expectType(boxen('unicorns', {padding: 3})); expectType(boxen('unicorns', {padding: spacing})); expectType(boxen('unicorns', {margin: 3})); expectType(boxen('unicorns', {margin: spacing})); expectType(boxen('unicorns', {float: 'center'})); expectType(boxen('unicorns', {backgroundColor: 'green'})); expectType(boxen('unicorns', {backgroundColor: '#ff0000'})); expectType(boxen('unicorns', {textAlignment: 'right'})); expectType(boxen('unicorns', {width: 20})); expectType(boxen('unicorns', {height: 5})); expectType(boxen('unicorns', {fullscreen: true})); boxen-7.1.1/license000066400000000000000000000021351445077726000142150ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. boxen-7.1.1/package.json000066400000000000000000000024031445077726000151340ustar00rootroot00000000000000{ "name": "boxen", "version": "7.1.1", "description": "Create boxes in the terminal", "license": "MIT", "repository": "sindresorhus/boxen", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "engines": { "node": ">=14.16" }, "scripts": { "test": "xo && nyc ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "cli", "box", "boxes", "terminal", "term", "console", "ascii", "unicode", "border", "text" ], "dependencies": { "ansi-align": "^3.0.1", "camelcase": "^7.0.1", "chalk": "^5.2.0", "cli-boxes": "^3.0.0", "string-width": "^5.1.2", "type-fest": "^2.13.0", "widest-line": "^4.0.1", "wrap-ansi": "^8.1.0" }, "devDependencies": { "ava": "^5.2.0", "nyc": "^15.1.0", "tsd": "^0.28.1", "xo": "^0.54.2" }, "ava": { "snapshotDir": "tests/snapshots", "environmentVariables": { "COLUMNS": "60", "FORCE_COLOR": "0" } }, "xo": { "rules": { "@typescript-eslint/no-redundant-type-constituents": "off", "unicorn/prefer-logical-operator-over-ternary": "off", "@typescript-eslint/no-unsafe-assignment": "off" } } } boxen-7.1.1/readme.md000066400000000000000000000124341445077726000144320ustar00rootroot00000000000000# boxen > Create boxes in the terminal ![](screenshot.png) ## Install ```sh npm install boxen ``` ## Usage ```js import boxen from 'boxen'; console.log(boxen('unicorn', {padding: 1})); /* ┌─────────────┐ │ │ │ unicorn │ │ │ └─────────────┘ */ console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'})); /* ╔═════════════╗ ║ ║ ║ unicorn ║ ║ ║ ╚═════════════╝ */ console.log(boxen('unicorns love rainbows', {title: 'magical', titleAlignment: 'center'})); /* ┌────── magical ───────┐ │unicorns love rainbows│ └──────────────────────┘ */ ``` ## API ### boxen(text, options?) #### text Type: `string` Text inside the box. #### options Type: `object` ##### borderColor Type: `string`\ Values: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'` Color of the box border. ##### borderStyle Type: `string | object`\ Default: `'single'`\ Values: - `'single'` ``` ┌───┐ │foo│ └───┘ ``` - `'double'` ``` ╔═══╗ ║foo║ ╚═══╝ ``` - `'round'` (`'single'` sides with round corners) ``` ╭───╮ │foo│ ╰───╯ ``` - `'bold'` ``` ┏━━━┓ ┃foo┃ ┗━━━┛ ``` - `'singleDouble'` (`'single'` on top and bottom, `'double'` on right and left) ``` ╓───╖ ║foo║ ╙───╜ ``` - `'doubleSingle'` (`'double'` on top and bottom, `'single'` on right and left) ``` ╒═══╕ │foo│ ╘═══╛ ``` - `'classic'` ``` +---+ |foo| +---+ ``` - `'arrow'` ``` ↘↓↓↓↙ →foo← ↗↑↑↑↖ ``` - `'none'` ``` foo ``` Style of the box border. Can be any of the above predefined styles or an object with the following keys: ```js { topLeft: '+', topRight: '+', bottomLeft: '+', bottomRight: '+', top: '-', bottom: '-', left: '|', right: '|' } ``` ##### dimBorder Type: `boolean`\ Default: `false` Reduce opacity of the border. ##### title Type: `string` Display a title at the top of the box. If needed, the box will horizontally expand to fit the title. Example: ```js console.log(boxen('foo bar', {title: 'example'})); /* ┌ example ┐ │foo bar │ └─────────┘ */ ``` ##### titleAlignment Type: `string`\ Default: `'left'` Align the title in the top bar. Values: - `'left'` ```js /* ┌ example ──────┐ │foo bar foo bar│ └───────────────┘ */ ``` - `'center'` ```js /* ┌─── example ───┐ │foo bar foo bar│ └───────────────┘ */ ``` - `'right'` ```js /* ┌────── example ┐ │foo bar foo bar│ └───────────────┘ */ ``` ##### width Type: `number` Set a fixed width for the box. *Note:* This disables terminal overflow handling and may cause the box to look broken if the user's terminal is not wide enough. ```js import boxen from 'boxen'; console.log(boxen('foo bar', {width: 15})); // ┌─────────────┐ // │foo bar │ // └─────────────┘ ``` ##### height Type: `number` Set a fixed height for the box. *Note:* This option will crop overflowing content. ```js import boxen from 'boxen'; console.log(boxen('foo bar', {height: 5})); // ┌───────┐ // │foo bar│ // │ │ // │ │ // └───────┘ ``` ##### fullscreen Type: `boolean | (width: number, height: number) => [width: number, height: number]` Whether or not to fit all available space within the terminal. Pass a callback function to control box dimensions: ```js import boxen from 'boxen'; console.log(boxen('foo bar', { fullscreen: (width, height) => [width, height - 1], })); ``` ##### padding Type: `number | object`\ Default: `0` Space between the text and box border. Accepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right padding is 3 times the top/bottom to make it look nice. ##### margin Type: `number | object`\ Default: `0` Space around the box. Accepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice. ##### float Type: `string`\ Default: `'left'`\ Values: `'right'` `'center'` `'left'` Float the box on the available terminal screen space. ##### backgroundColor Type: `string`\ Values: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'` Color of the background. ##### textAlignment Type: `string`\ Default: `'left'`\ Values: `'left'` `'center'` `'right'` Align the text in the box based on the widest line. ## Maintainer - [Sindre Sorhus](https://github.com/sindresorhus) - [Caesarovich](https://github.com/Caesarovich) ## Related - [boxen-cli](https://github.com/sindresorhus/boxen-cli) - CLI for this module - [cli-boxes](https://github.com/sindresorhus/cli-boxes) - Boxes for use in the terminal boxen-7.1.1/screenshot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+pVV ǎ=sƔ3 WB566WUTV8SPp\(yAqӃc+(}uX0EXJH~MRSEb8b]}dW"D K:f"T*έTװ?1$:E3.pHrPrP\-DgJt 5u?{w6P4 pb19A: q38(5:IvI۶^UuoBxﶻxwҵ]^y^yx hO)My|< * ܎tNVt5cSԔ.n&v^og0ff<_ݟi8.KV|+p Qp@hF(Q(@Q4 @h4 F(hF(Q(@Q4 @h4 F(hF(Q(Q4 @ٻ(( çWx&03e&l@M*]F(Q(@Q4 @h4 F(hF(Q(@Q4 @h4 F(hF(Q(@Q4 [>-@h4 F(hF(Q(@Q4 @h4 F(hF(Q(@Q4 F@9c Q4 _8(X< Qcl[3(~(#QX QdZw1褦Z4 [C@/c[9-FMݚ(ǚhe|5h|m6j]Ft<&..mԭٻY@Ff24 FQopR4 wF^wVhNn=(O(\ڨ[wsw`r2]__\^]ڨ[w=ppH:HMݚQ|w4 omn=FuO[5{Q8 ݼcG$5jҊU9.>Bطqc^3Q("Lfq' { const box = boxen('foo', {backgroundColor: 'red'}); t.snapshot(box); }); test('backgroundColor hex', t => { const box = boxen('foo', {backgroundColor: '#FF0000'}); t.snapshot(box); }); test('throws on unexpected backgroundColor', t => { t.throws(() => { boxen('foo', {backgroundColor: 'dark-yellow'}); }); }); boxen-7.1.1/tests/border-option.js000066400000000000000000000047051445077726000171400ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('border color (red)', t => { const box = boxen('foo', { borderColor: 'red', }); t.snapshot(box); }); test('border color (blue)', t => { const box = boxen('foo', { borderColor: 'blue', }); t.snapshot(box); }); test('border color (green)', t => { const box = boxen('foo', { borderColor: 'green', }); t.snapshot(box); }); test('border color (yellow + dim)', t => { const box = boxen('foo', { borderColor: 'green', dimBorder: true, }); t.snapshot(box); }); test('border color (hex)', t => { const box = boxen('foo', { borderColor: '#FF00FF', dimBorder: true, }); t.snapshot(box); }); test('throws on unexpected borderColor', t => { t.throws(() => { boxen('foo', {borderColor: 'greasy-white'}); }); }); test('border style (single)', t => { const box = boxen('foo', { borderStyle: 'single', }); t.snapshot(box); }); test('border style (singleDouble)', t => { const box = boxen('foo', { borderStyle: 'singleDouble', }); t.snapshot(box); }); test('border style (doubleSingle)', t => { const box = boxen('foo', { borderStyle: 'doubleSingle', }); t.snapshot(box); }); test('border style (double)', t => { const box = boxen('foo', { borderStyle: 'double', }); t.snapshot(box); }); test('border style (classic)', t => { const box = boxen('foo', { borderStyle: 'classic', }); t.snapshot(box); }); test('border style (bold)', t => { const box = boxen('foo', { borderStyle: 'bold', }); t.snapshot(box); }); test('border style (round)', t => { const box = boxen('foo', { borderStyle: 'round', }); t.snapshot(box); }); test('border style (none)', t => { const box = boxen('foo', { borderStyle: 'none', }); t.snapshot(box); }); test('border style (custom ascii style)', t => { const box = boxen('foo', { borderStyle: { topLeft: '1', topRight: '2', bottomLeft: '3', bottomRight: '4', left: '|', right: '!', top: '-', bottom: '_', }, }); t.snapshot(box); }); test('throws on unexpected borderStyle as string', t => { t.throws(() => { boxen('foo', {borderStyle: 'shakenSnake'}); }); }); test('throws on unexpected borderStyle as object', t => { t.throws(() => { boxen('foo', {borderStyle: {shake: 'snake'}}); }); // Missing bottomRight const invalid = { topLeft: '1', topRight: '2', bottomLeft: '3', horizontal: '-', vertical: '|', }; t.throws(() => { boxen('foo', {borderStyle: invalid}); }); }); boxen-7.1.1/tests/float-option.js000066400000000000000000000024361445077726000167670ustar00rootroot00000000000000import process from 'node:process'; import test from 'ava'; import boxen from '../index.js'; test('float option (left)', t => { const box = boxen('foo', { float: 'left', }); t.snapshot(box); }); test('float option (center)', t => { const box = boxen('foo', { float: 'center', }); t.snapshot(box); }); test('float option (right)', t => { const box = boxen('foo', { float: 'right', }); t.snapshot(box); }); test('float option (center) with margin', t => { const box = boxen('foo', { float: 'right', margin: { left: 3, top: 4, }, }); t.snapshot(box); }); test('float option (right) with margin', t => { const box = boxen('foo', { float: 'right', margin: { right: 2, bottom: 5, }, }); t.snapshot(box); }); test('float option (center) when content > columns', t => { const longContent = 'foobar'.repeat(process.env.COLUMNS); t.notThrows(() => { boxen(longContent, { float: 'center', }); }); const box = boxen(longContent, { float: 'center', }); t.snapshot(box); }); test('float option (right) when content > columns', t => { const longContent = 'foobar'.repeat(process.env.COLUMNS); t.notThrows(() => { boxen(longContent, { float: 'right', }); }); const box = boxen(longContent, { float: 'right', }); t.snapshot(box); }); boxen-7.1.1/tests/fullscreen-option.js000066400000000000000000000011211445077726000200120ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('fullscreen option', t => { const box = boxen('foo', { fullscreen: true, }); t.snapshot(box); }); test('fullscreen option + width', t => { const box = boxen('foo', { fullscreen: true, width: 10, }); t.snapshot(box); }); test('fullscreen option + height', t => { const box = boxen('foo', { fullscreen: true, height: 10, }); t.snapshot(box); }); test('fullscreen option with callback', t => { const box = boxen('foo', { fullscreen: (width, height) => [width - 2, height - 2], }); t.snapshot(box); }); boxen-7.1.1/tests/height-option.js000066400000000000000000000017661445077726000171370ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('height option works', t => { // Creates a tall box with empty rows t.snapshot( boxen('foo', { height: 5, }), ); // Creates a 1 line box, cropping the other lines t.snapshot( boxen('foo bar\nfoo bar', { height: 3, }), ); }); test('height option with padding + margin', t => { // Creates a wide box for little text const box = boxen('foo', { height: 20, margin: 2, padding: 1, }); t.snapshot(box); }); test('height option with width', t => { // Creates a wide box for little text const box = boxen('foo', { height: 5, width: 20, }); t.snapshot(box); }); test('height option with width + padding + margin', t => { // Creates a wide box for little text const box = boxen('foo', { height: 5, width: 20, margin: 2, padding: 1, }); t.snapshot(box); }); test('height option with border style (none)', t => { const box = boxen('foo', { height: 3, borderStyle: 'none', }); t.snapshot(box); }); boxen-7.1.1/tests/main.js000066400000000000000000000053321445077726000152760ustar00rootroot00000000000000import process from 'node:process'; import test from 'ava'; import chalk from 'chalk'; import boxen from '../index.js'; const longText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas id erat arcu. Integer urna mauris, sodales vel egestas eu, consequat id turpis. Vivamus faucibus est mattis tincidunt lobortis. In aliquam placerat nunc eget viverra. Duis aliquet faucibus diam, blandit tincidunt magna congue eu. Sed vel ante vestibulum, maximus risus eget, iaculis velit. Quisque id dapibus purus, ut sodales lorem. Aenean laoreet iaculis tellus at malesuada. Donec imperdiet eu lacus vitae fringilla.'; const formattedText = ` !!! Unicorns are lit !!! Hello this is a formatted text ! It has alignements already includes${' '} in it.${' '} Boxen should protect this alignement, otherwise the users would be sad ! Hehe Haha${' '.repeat(33)} Hihi Hoho All this garbage is on purpose. Have a good day ! `; const randomText = 'lewb{+^PN_6-l 8eK2eqB:jn^YFgGl;wuT)mdA9TZlf 9}?X#P49`x"@+nLx:BH5p{5_b`S\'E8\0{A0l"(62`TIf(z8n2arEY~]y|bk,6,FYf~rGY*Xfa00q{=fdm=4.zVf6#\'|3S!`pJ3 6y02]nj2o4?-`1v$mudH?Wbw3fZ]a+aE\'\'P4Q(6:NHBry)L_&/7v]0\0~y8PZ*|-BRY&m%UaCe\'3A,N?8&wbOP}*.O<47rnPzxO=4"*|[%A):;E)Z6!V&x!1*OprW-*+qUp&=P6M_VGx0O/VOvPEez:7C58a^.N,"Rxc|a6C[i$3QC_)~x!wd+ZMtYsGF&?'; test('creates a box', t => { const box = boxen('foo'); t.snapshot(box); }); test('box not overflowing terminal', t => { const box = boxen('foo'.repeat(process.env.COLUMNS)); t.snapshot(box); }); test('box not overflowing terminal with padding', t => { const box = boxen('foo'.repeat(process.env.COLUMNS), { padding: 3, }); t.snapshot(box); }); test('box not overflowing terminal with words', t => { const box = boxen('foo '.repeat(process.env.COLUMNS)); t.snapshot(box); }); test('box not overflowing terminal with words + padding', t => { const box = boxen('foo '.repeat(process.env.COLUMNS), { padding: 2, }); t.snapshot(box); }); test('box not overflowing terminal with words + padding + margin', t => { const box = boxen('foo '.repeat(process.env.COLUMNS), { padding: 2, magin: 1, }); t.snapshot(box); }); test('handles long text', t => { const box = boxen(longText); t.snapshot(box); }); test('handles formatted text', t => { const box = boxen(formattedText); t.snapshot(box); }); test('handles random text', t => { const box = boxen(randomText); t.snapshot(box); }); test('handles colored texts', t => { let box = boxen(chalk.red(longText)); t.snapshot(box); box = boxen(chalk.blue(formattedText)); t.snapshot(box); box = boxen(chalk.yellow(randomText)); t.snapshot(box); }); boxen-7.1.1/tests/margin-option.js000066400000000000000000000021221445077726000171270ustar00rootroot00000000000000import process from 'node:process'; import test from 'ava'; import boxen from '../index.js'; test('margin option works', t => { const box = boxen('foo', { margin: 2, }); t.snapshot(box); }); test('margin option with custom margins', t => { const box = boxen('foo', { margin: { top: 1, left: 2, right: 3, bottom: 4, }, }); t.snapshot(box); }); test('margin option with padding', t => { const box = boxen('foo', { margin: 1, padding: 1, }); t.snapshot(box); }); test('margin proportionally decreases when content <= columns', t => { // Plenty space let box = boxen('x'.repeat((process.env.COLUMNS / 2) - 2), { margin: 2, }); t.snapshot(box); // A bit of space box = boxen('x'.repeat(process.env.COLUMNS - 6 - 2), { margin: 2, }); t.snapshot(box); // No room box = boxen('ax'.repeat(process.env.COLUMNS - 2), { margin: 2, }); t.snapshot(box); }); test('margin option with border style (none)', t => { const box = boxen('foo', { margin: { top: 1, bottom: 1, left: 1, right: 1, }, borderStyle: 'none', }); t.snapshot(box); }); boxen-7.1.1/tests/padding-option.js000066400000000000000000000010241445077726000172600ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('padding option works', t => { const box = boxen('foo', { padding: 2, }); t.snapshot(box); }); test('padding option advanced', t => { const box = boxen('foo', { padding: { top: 0, bottom: 2, left: 5, right: 10, }, }); t.snapshot(box); }); test('padding option with border style (none)', t => { const box = boxen('foo', { padding: { top: 1, bottom: 1, left: 1, right: 1, }, borderStyle: 'none', }); t.snapshot(box); }); boxen-7.1.1/tests/snapshots/000077500000000000000000000000001445077726000160335ustar00rootroot00000000000000boxen-7.1.1/tests/snapshots/tests/000077500000000000000000000000001445077726000171755ustar00rootroot00000000000000boxen-7.1.1/tests/snapshots/tests/background-option.js.md000066400000000000000000000005461445077726000235640ustar00rootroot00000000000000# Snapshot report for `tests/background-option.js` The actual snapshot is saved in `background-option.js.snap`. Generated by [AVA](https://avajs.dev). ## backgroundColor option > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## backgroundColor hex > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` boxen-7.1.1/tests/snapshots/tests/background-option.js.snap000066400000000000000000000002571445077726000241240ustar00rootroot00000000000000AVA Snapshot v3 ǜ# zx{K^!AGl+WI[]ܴ($$',)19;(4/9?'H!$3?/8/8#qaJJbIb93;022j>hJ Mz4)-?HYSdf@)F'#z߫8boxen-7.1.1/tests/snapshots/tests/border-option.js.md000066400000000000000000000027401445077726000227200ustar00rootroot00000000000000# Snapshot report for `tests/border-option.js` The actual snapshot is saved in `border-option.js.snap`. Generated by [AVA](https://avajs.dev). ## border color (red) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border color (blue) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border color (green) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border color (yellow + dim) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border color (hex) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border style (single) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## border style (singleDouble) > Snapshot 1 `╓───╖␊ ║foo║␊ ╙───╜` ## border style (doubleSingle) > Snapshot 1 `╒═══╕␊ │foo│␊ ╘═══╛` ## border style (double) > Snapshot 1 `╔═══╗␊ ║foo║␊ ╚═══╝` ## border style (classic) > Snapshot 1 `+---+␊ |foo|␊ +---+` ## border style (bold) > Snapshot 1 `┏━━━┓␊ ┃foo┃␊ ┗━━━┛` ## border style (round) > Snapshot 1 `╭───╮␊ │foo│␊ ╰───╯` ## border style (none) > Snapshot 1 'foo' ## border style (custom ascii style) > Snapshot 1 `1---2␊ |foo!␊ 3___4` boxen-7.1.1/tests/snapshots/tests/border-option.js.snap000066400000000000000000000006551445077726000232640ustar00rootroot00000000000000AVA Snapshot v3 q蕢<.q "t\NN@!Ętڅe!,I|_q״&33UHXltE$ՙ.js$9wv0qO cHBK0fB@̳Xp6Z`sR,FZnu\&51M|.PE`:>,uHBOoĘ\M^r_<Ï04 yNEtMS=(/4qzw$%Tob(AnS2lzTsc\l3 ζƩ6[VC#Sgsua0Jj&Gٌe7We,c%"^iPl+2?90[jd}Iϴ׷CޑF!׌=˲?Xiboxen-7.1.1/tests/snapshots/tests/float-option.js.md000066400000000000000000000062051445077726000225500ustar00rootroot00000000000000# Snapshot report for `tests/float-option.js` The actual snapshot is saved in `float-option.js.snap`. Generated by [AVA](https://avajs.dev). ## float option (left) > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## float option (center) > Snapshot 1 ` ┌───┐␊ │foo│␊ └───┘` ## float option (right) > Snapshot 1 ` ┌───┐␊ │foo│␊ └───┘` ## float option (center) with margin > Snapshot 1 `␊ ␊ ␊ ␊ ┌───┐␊ │foo│␊ └───┘` ## float option (right) with margin > Snapshot 1 ` ┌───┐␊ │foo│␊ └───┘␊ ␊ ␊ ␊ ␊ ` ## float option (center) when content > columns > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob│␊ │arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo│␊ │obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar│␊ │foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob│␊ │arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo│␊ │obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar│␊ │foobarfoobar │␊ └──────────────────────────────────────────────────────────┘` ## float option (right) when content > columns > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob│␊ │arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo│␊ │obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar│␊ │foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob│␊ │arfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo│␊ │obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar│␊ │foobarfoobar │␊ └──────────────────────────────────────────────────────────┘` boxen-7.1.1/tests/snapshots/tests/float-option.js.snap000066400000000000000000000005721445077726000231120ustar00rootroot00000000000000AVA Snapshot v3 dTmfVi/c P7W[]ܾ($$'8-'?D!$3?OA#'5D38/8#qaJJbIb93;022j>hJ Mz4)-?HYSdf@-)E$95$5(T).8EB.1 O!¿ X#Q<$C!7(=33d%. U:t%s%pΒl, Z" .:8RMFjBr>W`dcQ$=J 0wH XXD )V "kbԀaZ6$|^>f!FF6 ,w boxen-7.1.1/tests/snapshots/tests/fullscreen-option.js.md000066400000000000000000000013361445077726000236050ustar00rootroot00000000000000# Snapshot report for `tests/fullscreen-option.js` The actual snapshot is saved in `fullscreen-option.js.snap`. Generated by [AVA](https://avajs.dev). ## fullscreen option > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## fullscreen option + width > Snapshot 1 `┌────────┐␊ │foo │␊ └────────┘` ## fullscreen option + height > Snapshot 1 `┌───┐␊ │foo│␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ └───┘` ## fullscreen option with callback > Snapshot 1 `┌───┐␊ │foo│␊ └───┘` boxen-7.1.1/tests/snapshots/tests/fullscreen-option.js.snap000066400000000000000000000003601445077726000241420ustar00rootroot00000000000000AVA Snapshot v3  Ȣ;#?Zx :!B|mJKU[]ܲ($$'04'8(55O!$3?/8/8#qaJJbIb93;022j>hJ Mz4)-?HYSdf@İCA[<3$Ӯ(|PBC0@~4w6dfg`=w%,!(̒ ĜlEn boxen-7.1.1/tests/snapshots/tests/height-option.js.md000066400000000000000000000034201445077726000227070ustar00rootroot00000000000000# Snapshot report for `tests/height-option.js` The actual snapshot is saved in `height-option.js.snap`. Generated by [AVA](https://avajs.dev). ## height option works > Snapshot 1 `┌───┐␊ │foo│␊ │ │␊ │ │␊ └───┘` > Snapshot 2 `┌───────┐␊ │foo bar│␊ └───────┘` ## height option with padding + margin > Snapshot 1 `␊ ␊ ┌─────────┐␊ │ │␊ │ foo │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ │ │␊ └─────────┘␊ ␊ ` ## height option with width > Snapshot 1 `┌──────────────────┐␊ │foo │␊ │ │␊ │ │␊ └──────────────────┘` ## height option with width + padding + margin > Snapshot 1 `␊ ␊ ┌──────────────────┐␊ │ │␊ │ foo │␊ │ │␊ └──────────────────┘␊ ␊ ` ## height option with border style (none) > Snapshot 1 `foo␊ ␊ ` boxen-7.1.1/tests/snapshots/tests/height-option.js.snap000066400000000000000000000005721445077726000232550ustar00rootroot00000000000000AVA Snapshot v3 ݒ~Qr"΋SQc []ܺ($$'8#53=D!$3?O<(88/8#iaJJbIb73;022>hJ Mz4)-?HX )Hg@ F1,+$%af@T̒ Ĕ̼tmĢ<'!.d|$\\ `m05)ȥȢ `bW;*J Q\V`EKj)L)H"QRB)o&kT:I-6`f'+J Snapshot 1 `┌───┐␊ │foo│␊ └───┘` ## box not overflowing terminal > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof│␊ │oofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofo│␊ │ofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo│␊ │foofoo │␊ └──────────────────────────────────────────────────────────┘` ## box not overflowing terminal with padding > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │ │␊ │ │␊ │ │␊ │ foofoofoofoofoofoofoofoofoofoofoofoofoof │␊ │ oofoofoofoofoofoofoofoofoofoofoofoofoofo │␊ │ ofoofoofoofoofoofoofoofoofoofoofoofoofoo │␊ │ foofoofoofoofoofoofoofoofoofoofoofoofoof │␊ │ oofoofoofoofoofoofoo │␊ │ │␊ │ │␊ │ │␊ └──────────────────────────────────────────────────────────┘` ## box not overflowing terminal with words > Snapshot 1 `┌────────────────────────────────────────────────────────┐␊ │foo foo foo foo foo foo foo foo foo foo foo foo foo foo │␊ │foo foo foo foo foo foo foo foo foo foo foo foo foo foo │␊ │foo foo foo foo foo foo foo foo foo foo foo foo foo foo │␊ │foo foo foo foo foo foo foo foo foo foo foo foo foo foo │␊ │foo foo foo foo │␊ └────────────────────────────────────────────────────────┘` ## box not overflowing terminal with words + padding > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │ │␊ │ │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo │␊ │ │␊ │ │␊ └──────────────────────────────────────────────────────────┘` ## box not overflowing terminal with words + padding + margin > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │ │␊ │ │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo foo foo foo foo foo foo │␊ │ foo foo foo foo foo │␊ │ │␊ │ │␊ └──────────────────────────────────────────────────────────┘` ## handles long text > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │Lorem ipsum dolor sit amet, consectetur adipiscing elit. │␊ │Maecenas id erat arcu. Integer urna mauris, sodales vel │␊ │egestas eu, consequat id turpis. Vivamus faucibus est │␊ │mattis tincidunt lobortis. In aliquam placerat nunc eget │␊ │viverra. Duis aliquet faucibus diam, blandit tincidunt │␊ │magna congue eu. Sed vel ante vestibulum, maximus risus │␊ │eget, iaculis velit. Quisque id dapibus purus, ut sodales │␊ │lorem. Aenean laoreet iaculis tellus at malesuada. Donec │␊ │imperdiet eu lacus vitae fringilla. │␊ └──────────────────────────────────────────────────────────┘` ## handles formatted text > Snapshot 1 `┌───────────────────────────────────────────────────┐␊ │ │␊ │!!! Unicorns are lit !!! │␊ │Hello this is a formatted text ! │␊ │ It has alignements │␊ │ already includes │␊ │ in it. │␊ │Boxen should protect this alignement, │␊ │ otherwise the users would be sad ! │␊ │Hehe Haha │␊ │Hihi Hoho │␊ │ All this garbage is on purpose. │␊ │Have a good day ! │␊ │ │␊ └───────────────────────────────────────────────────┘` ## handles random text > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │lewb{+^PN_6-l 8eK2eqB:jn^YFgGl;wuT)mdA9TZlf │␊ │9}?X#P49\`x"@+nLx:BH5p{5_b\`S'E8{A0l"(62\`TIf(z8n2arEY~]y|bk,│␊ │6,FYf~rGY*Xfa00q{=fdm=4.zVf6#'|3S!\`pJ3 │␊ │6y02]nj2o4?-\`1v$mudH?Wbw3fZ]a+aE''P4Q(6:NHBry)L_&/7v]0~y8PZ*|-BRY&m%UaCe'3A,N?8&wbOP}*.O<47rnPzxO=4│␊ │"*|[%A):;E)Z6!V&x!1*OprW-*+qUp&=P6M_VGx0O│␊ │/VOvPEez:7C58a^.N,"Rxc|a6C[i$3QC_)~x!wd+ZMtYsGF&? │␊ └──────────────────────────────────────────────────────────┘` ## handles colored texts > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │Lorem ipsum dolor sit amet, consectetur adipiscing elit. │␊ │Maecenas id erat arcu. Integer urna mauris, sodales vel │␊ │egestas eu, consequat id turpis. Vivamus faucibus est │␊ │mattis tincidunt lobortis. In aliquam placerat nunc eget │␊ │viverra. Duis aliquet faucibus diam, blandit tincidunt │␊ │magna congue eu. Sed vel ante vestibulum, maximus risus │␊ │eget, iaculis velit. Quisque id dapibus purus, ut sodales │␊ │lorem. Aenean laoreet iaculis tellus at malesuada. Donec │␊ │imperdiet eu lacus vitae fringilla. │␊ └──────────────────────────────────────────────────────────┘` > Snapshot 2 `┌───────────────────────────────────────────────────┐␊ │ │␊ │!!! Unicorns are lit !!! │␊ │Hello this is a formatted text ! │␊ │ It has alignements │␊ │ already includes │␊ │ in it. │␊ │Boxen should protect this alignement, │␊ │ otherwise the users would be sad ! │␊ │Hehe Haha │␊ │Hihi Hoho │␊ │ All this garbage is on purpose. │␊ │Have a good day ! │␊ │ │␊ └───────────────────────────────────────────────────┘` > Snapshot 3 `┌──────────────────────────────────────────────────────────┐␊ │lewb{+^PN_6-l 8eK2eqB:jn^YFgGl;wuT)mdA9TZlf │␊ │9}?X#P49\`x"@+nLx:BH5p{5_b\`S'E8{A0l"(62\`TIf(z8n2arEY~]y|bk,│␊ │6,FYf~rGY*Xfa00q{=fdm=4.zVf6#'|3S!\`pJ3 │␊ │6y02]nj2o4?-\`1v$mudH?Wbw3fZ]a+aE''P4Q(6:NHBry)L_&/7v]0~y8PZ*|-BRY&m%UaCe'3A,N?8&wbOP}*.O<47rnPzxO=4│␊ │"*|[%A):;E)Z6!V&x!1*OprW-*+qUp&=P6M_VGx0O│␊ │/VOvPEez:7C58a^.N,"Rxc|a6C[i$3QC_)~x!wd+ZMtYsGF&? │␊ └──────────────────────────────────────────────────────────┘` boxen-7.1.1/tests/snapshots/tests/main.js.snap000066400000000000000000000027511445077726000214240ustar00rootroot00000000000000AVA Snapshot v3 aSUOB܎J(ZPɾK\<XMWZG6&==.5Ə5(&FIF1;ܙܹ|(vE.m7/Ü+^>ϼ>3OڑDQňIF1Ǧ'] oi>Ͼ)_?~4.Y7JٯqHg"Cy)" 1];__]a[\嬴x'e(B j]C[\z-PD&u,(8]WOm"hTW4Z;W4;t-kD(#nYHPuwwV7(ufJUo4AMB+_:'3LP1NP*ASJԍ%\gBL %.k׶!iYT!lCQDX&4D _+L4±ĀG\ȖڒZ>d ;Mv3xR'vǔ ,B~Iذ-ǶFcpW f)5\ńTt#(dX+m!TU c|d ,c8AIq&SXnʝ4=$p -WW Wy]l@Vـ$U?j緶p0x"A&<{o=>6ם'gz#'ٞg^'cuwhdn< ]?:#X\>v+1}xA.Exh(u2׍x3uG]k <N}ˌƷwHjx^<+ӻCӮQX7>\UMDo @ܣsىLl-~6 Snapshot 1 `␊ ␊ ┌───┐␊ │foo│␊ └───┘␊ ␊ ` ## margin option with custom margins > Snapshot 1 `␊ ┌───┐␊ │foo│␊ └───┘␊ ␊ ␊ ␊ ` ## margin option with padding > Snapshot 1 `␊ ┌─────────┐␊ │ │␊ │ foo │␊ │ │␊ └─────────┘␊ ` ## margin proportionally decreases when content <= columns > Snapshot 1 `␊ ␊ ┌────────────────────────────┐␊ │xxxxxxxxxxxxxxxxxxxxxxxxxxxx│␊ └────────────────────────────┘␊ ␊ ` > Snapshot 2 `␊ ␊ ┌────────────────────────────────────────────────────┐␊ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│␊ └────────────────────────────────────────────────────┘␊ ␊ ` > Snapshot 3 `␊ ␊ ┌──────────────────────────────────────────────────────────┐␊ │axaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxax│␊ │axaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxaxax│␊ └──────────────────────────────────────────────────────────┘␊ ␊ ` ## margin option with border style (none) > Snapshot 1 `␊ foo␊ ` boxen-7.1.1/tests/snapshots/tests/margin-option.js.snap000066400000000000000000000006451445077726000232630ustar00rootroot00000000000000AVA Snapshot v3 5SBVzˁ]NdȶxՀ-X8AyU=O0M@䍕,v$;n6V_djA JdR~Z@ A>L@(r{tu;.X}yBS.=1C}$'t@ɛmE.׍-#6s6OŸ6u<:D=,dMJ 6SR/JJ"]j_;x6:Sw@>I8$X Uӧy#Gi#D q%(TC9+>>݁Wd6 ݢf&hEF#!|.h߈M[?4r {IHWHY< zŲplixMjRρӃB(G6Q|boxen-7.1.1/tests/snapshots/tests/padding-option.js.md000066400000000000000000000014641445077726000230530ustar00rootroot00000000000000# Snapshot report for `tests/padding-option.js` The actual snapshot is saved in `padding-option.js.snap`. Generated by [AVA](https://avajs.dev). ## padding option works > Snapshot 1 `┌───────────────┐␊ │ │␊ │ │␊ │ foo │␊ │ │␊ │ │␊ └───────────────┘` ## padding option advanced > Snapshot 1 `┌──────────────────┐␊ │ foo │␊ │ │␊ │ │␊ └──────────────────┘` ## padding option with border style (none) > Snapshot 1 ` ␊ foo ␊ ` boxen-7.1.1/tests/snapshots/tests/padding-option.js.snap000066400000000000000000000003761445077726000234150ustar00rootroot00000000000000AVA Snapshot v3 K"&"m/А[]ܼ($$' 1%%3/]!$3?O<(88/8#qaJJbIbfv`dedhJϣ) \4)!Ѵ|բN!х3AR$)eyɩ)r%T*Xc#,A1B=add($)T*hjb Snapshot 1 `┌────────────────┐␊ │Hello there ! │␊ │General Kenobi !│␊ └────────────────┘` ## text alignement option (center) > Snapshot 1 `┌────────────────┐␊ │ Hello there ! │␊ │General Kenobi !│␊ └────────────────┘` ## text alignement option (right) > Snapshot 1 `┌────────────────┐␊ │ Hello there !│␊ │General Kenobi !│␊ └────────────────┘` ## text alignement option (left) + padding > Snapshot 1 `┌──────────────────────┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └──────────────────────┘` ## text alignement option (center) + padding > Snapshot 1 `┌──────────────────────┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └──────────────────────┘` ## text alignement option (right) + padding > Snapshot 1 `┌──────────────────────┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └──────────────────────┘` ## text alignement option (left) + long title > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │Hello there ! │␊ │General Kenobi ! │␊ └───────────────────────────────┘` ## text alignement option (center) + long title > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │ Hello there ! │␊ │ General Kenobi ! │␊ └───────────────────────────────┘` ## text alignement option (right) + long title > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │ Hello there !│␊ │ General Kenobi !│␊ └───────────────────────────────┘` ## text alignement option (left) + long title + padding > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘` ## text alignement option (center) + long title + padding > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘` ## text alignement option (right) + long title + padding > Snapshot 1 `┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘` ## text alignement option (left) + long title + padding + margin > Snapshot 1 `␊ ┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘␊ ` ## text alignement option (center) + long title + padding + margin > Snapshot 1 `␊ ┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘␊ ` ## text alignement option (right) + long title + padding + margin > Snapshot 1 `␊ ┌ This is a famous movie quote: ┐␊ │ │␊ │ Hello there ! │␊ │ General Kenobi ! │␊ │ │␊ └───────────────────────────────┘␊ ` ## text alignement option (center) after wrapping > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │Lorem ipsum dolor sit amet, consectetur adipiscing elit. │␊ │ Maecenas id erat arcu. Integer urna mauris, sodales vel │␊ │ egestas eu, consequat id turpis. Vivamus faucibus est │␊ │mattis tincidunt lobortis. In aliquam placerat nunc eget │␊ │ viverra. Duis aliquet faucibus diam, blandit tincidunt │␊ │ magna congue eu. Sed vel ante vestibulum, maximus risus │␊ │eget, iaculis velit. Quisque id dapibus purus, ut sodales │␊ │lorem. Aenean laoreet iaculis tellus at malesuada. Donec │␊ │ imperdiet eu lacus vitae fringilla. │␊ └──────────────────────────────────────────────────────────┘` ## text alignement option (right) after wrapping > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │ Lorem ipsum dolor sit amet, consectetur adipiscing elit.│␊ │ Maecenas id erat arcu. Integer urna mauris, sodales vel│␊ │ egestas eu, consequat id turpis. Vivamus faucibus est│␊ │ mattis tincidunt lobortis. In aliquam placerat nunc eget│␊ │ viverra. Duis aliquet faucibus diam, blandit tincidunt│␊ │ magna congue eu. Sed vel ante vestibulum, maximus risus│␊ │ eget, iaculis velit. Quisque id dapibus purus, ut sodales│␊ │ lorem. Aenean laoreet iaculis tellus at malesuada. Donec│␊ │ imperdiet eu lacus vitae fringilla.│␊ └──────────────────────────────────────────────────────────┘` ## text alignement option (center) after wrapping + padding > Snapshot 1 `┌──────────────────────────────────────────────────────────┐␊ │ │␊ │ Lorem ipsum dolor sit amet, consectetur adipiscing │␊ │ elit. Maecenas id erat arcu. Integer urna mauris, │␊ │ sodales vel egestas eu, consequat id turpis. Vivamus │␊ │ faucibus est mattis tincidunt lobortis. In aliquam │␊ │ placerat nunc eget viverra. Duis aliquet faucibus │␊ │ diam, blandit tincidunt magna congue eu. Sed vel │␊ │ ante vestibulum, maximus risus eget, iaculis velit. │␊ │ Quisque id dapibus purus, ut sodales lorem. Aenean │␊ │ laoreet iaculis tellus at malesuada. Donec imperdiet │␊ │ eu lacus vitae fringilla. │␊ │ │␊ └──────────────────────────────────────────────────────────┘` ## text alignement option (right) after wrapping + padding + margin > Snapshot 1 `␊ ┌──────────────────────────────────────────────────────────┐␊ │ │␊ │ Lorem ipsum dolor sit amet, consectetur adipiscing │␊ │ elit. Maecenas id erat arcu. Integer urna mauris, │␊ │ sodales vel egestas eu, consequat id turpis. Vivamus │␊ │ faucibus est mattis tincidunt lobortis. In aliquam │␊ │ placerat nunc eget viverra. Duis aliquet faucibus │␊ │ diam, blandit tincidunt magna congue eu. Sed vel │␊ │ ante vestibulum, maximus risus eget, iaculis velit. │␊ │ Quisque id dapibus purus, ut sodales lorem. Aenean │␊ │ laoreet iaculis tellus at malesuada. Donec imperdiet │␊ │ eu lacus vitae fringilla. │␊ │ │␊ └──────────────────────────────────────────────────────────┘␊ ` boxen-7.1.1/tests/snapshots/tests/text-align-option.js.snap000066400000000000000000000021101445077726000240470ustar00rootroot00000000000000AVA Snapshot v3 3;b+c",c#Fdɗg\ U: /sL֚ $1*\>]ξr=ީm)mG8ɇIfkjAViۥJ~UWҶKE(R }e[5^$&@u#5[V~)4$Gz݈Vw34s3&K}Ba6*լ.{֓r̥%G?V WtKڷ\RZ+pцd"W-"p. jDJ$:>ƶ%v,ӴcMxpܪ'n9r:恫Y_ OF;fPV$ S_N8~.+~^6H* #/T1T&4FY"&)LgcBQ5IVr%fQ,A$}ic=i4@Μ͠9's6& @@Lx7L.Ri;AFsxRV0fc]c+Ɏ|F 8>j3gf #>2SNTo"A+`N pc~X!|+ 2(S%w p>2$8Ġ|`[_^!U>Ԡ)G&88Q`‚oPP $E0[A= Ԅ@mLWP!%pQpڱ sCtxPͥS  ]\ҀqV=Q5r) M@9$8H*w:q T8hR]"C*^ݮt)BwD#+gew%boxen-7.1.1/tests/snapshots/tests/title-option.js.md000066400000000000000000000025071445077726000225650ustar00rootroot00000000000000# Snapshot report for `tests/title-option.js` The actual snapshot is saved in `title-option.js.snap`. Generated by [AVA](https://avajs.dev). ## title option works > Snapshot 1 `┌ title ┐␊ │foo │␊ └───────┘` ## title align left > Snapshot 1 `┌ title ────────┐␊ │foo bar foo bar│␊ └───────────────┘` ## title align center > Snapshot 1 `┌──── title ────┐␊ │foo bar foo bar│␊ └───────────────┘` ## title align right > Snapshot 1 `┌──────── title ┐␊ │foo bar foo bar│␊ └───────────────┘` ## long title expands box > Snapshot 1 `┌ very long title ┐␊ │foo │␊ └─────────────────┘` ## title + width option > Snapshot 1 `┌─┐␊ │f│␊ │o│␊ │o│␊ └─┘` > Snapshot 2 `┌ v ┐␊ │foo│␊ └───┘` > Snapshot 3 `┌ very long title ─┐␊ │foo │␊ └──────────────────┘` ## title option with border style (none) > Snapshot 1 `title␊ foo ` boxen-7.1.1/tests/snapshots/tests/title-option.js.snap000066400000000000000000000005771445077726000231330ustar00rootroot00000000000000AVA Snapshot v3 LMVJn’?p~m*3浧hN0S!T&F6K ԉ 8lIP( C$UГۊ~;afI )@.W*6QD5}z< ΂mLN}[_Ӷ^n궮Fc+&f<$c뽠zJbyF1s&4b'}vI%O҃,h DbYS)Bo/q16%fNDZ|rp5p5V \m:_Qb>O5fѿ Snapshot 1 `┌──────────────────┐␊ │foo │␊ └──────────────────┘` > Snapshot 2 `┌────────┐␊ │foo bar │␊ │foo bar │␊ └────────┘` ## width option with padding + margin > Snapshot 1 `␊ ␊ ┌──────────────────┐␊ │ │␊ │ foo │␊ │ │␊ └──────────────────┘␊ ␊ ` ## width option with big padding > Snapshot 1 `┌────┐␊ │ │␊ │ │␊ │ │␊ │foo │␊ │ │␊ │ │␊ │ │␊ └────┘` ## width option with border style (none) > Snapshot 1 'foo' boxen-7.1.1/tests/snapshots/tests/width-option.js.snap000066400000000000000000000005001445077726000231130ustar00rootroot00000000000000AVA Snapshot v3  g`d*p.A;rEWǙ_[]ܲ($$'<3$C!$3?O<(88/8#iaJJbIbBfv`dedhJϣ) d \4+ Pb ΀:4١x wIRb~4.̀_je))y Eyl:+Jx>c₅ H 4ZKM~ qqL3Ȓ2aZ (ZHD$"L* qE)E %9 yyDq?3!'boxen-7.1.1/tests/text-align-option.js000066400000000000000000000104071445077726000177330ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; const longText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas id erat arcu. Integer urna mauris, sodales vel egestas eu, consequat id turpis. Vivamus faucibus est mattis tincidunt lobortis. In aliquam placerat nunc eget viverra. Duis aliquet faucibus diam, blandit tincidunt magna congue eu. Sed vel ante vestibulum, maximus risus eget, iaculis velit. Quisque id dapibus purus, ut sodales lorem. Aenean laoreet iaculis tellus at malesuada. Donec imperdiet eu lacus vitae fringilla.'; test('text alignement option (left)', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'left', }); t.snapshot(box); }); test('text alignement option (center)', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'center', }); t.snapshot(box); }); test('text alignement option (right)', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'right', }); t.snapshot(box); }); test('text alignement option (left) + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'left', padding: 1, }); t.snapshot(box); }); test('text alignement option (center) + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'center', padding: 1, }); t.snapshot(box); }); test('text alignement option (right) + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'right', padding: 1, }); t.snapshot(box); }); test('text alignement option (left) + long title', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'left', title: 'This is a famous movie quote:', }); t.snapshot(box); }); test('text alignement option (center) + long title', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'center', title: 'This is a famous movie quote:', }); t.snapshot(box); }); test('text alignement option (right) + long title', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'right', title: 'This is a famous movie quote:', }); t.snapshot(box); }); test('text alignement option (left) + long title + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'left', title: 'This is a famous movie quote:', padding: 1, }); t.snapshot(box); }); test('text alignement option (center) + long title + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'center', title: 'This is a famous movie quote:', padding: 1, }); t.snapshot(box); }); test('text alignement option (right) + long title + padding', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'right', title: 'This is a famous movie quote:', padding: 1, }); t.snapshot(box); }); test('text alignement option (left) + long title + padding + margin', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'left', title: 'This is a famous movie quote:', margin: 1, padding: 1, }); t.snapshot(box); }); test('text alignement option (center) + long title + padding + margin', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'center', title: 'This is a famous movie quote:', margin: 1, padding: 1, }); t.snapshot(box); }); test('text alignement option (right) + long title + padding + margin', t => { const box = boxen('Hello there !\nGeneral Kenobi !', { textAlignment: 'right', title: 'This is a famous movie quote:', margin: 1, padding: 1, }); t.snapshot(box); }); test('text alignement option (center) after wrapping', t => { const box = boxen(longText, { textAlignment: 'center', }); t.snapshot(box); }); test('text alignement option (right) after wrapping', t => { const box = boxen(longText, { textAlignment: 'right', }); t.snapshot(box); }); test('text alignement option (center) after wrapping + padding', t => { const box = boxen(longText, { textAlignment: 'center', padding: 1, }); t.snapshot(box); }); test('text alignement option (right) after wrapping + padding + margin', t => { const box = boxen(longText, { textAlignment: 'center', margin: 1, padding: 1, }); t.snapshot(box); }); boxen-7.1.1/tests/title-option.js000066400000000000000000000023231445077726000167760ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('title option works', t => { const box = boxen('foo', { title: 'title', }); t.snapshot(box); }); test('title align left', t => { const box = boxen('foo bar foo bar', { title: 'title', titleAlignment: 'left', }); t.snapshot(box); }); test('title align center', t => { const box = boxen('foo bar foo bar', { title: 'title', titleAlignment: 'center', }); t.snapshot(box); }); test('title align right', t => { const box = boxen('foo bar foo bar', { title: 'title', titleAlignment: 'right', }); t.snapshot(box); }); test('long title expands box', t => { const box = boxen('foo', { title: 'very long title', }); t.snapshot(box); }); test('title + width option', t => { // Not enough space, no title t.snapshot( boxen('foo', { title: 'very long title', width: 3, }), ); // Space for only one character t.snapshot( boxen('foo', { title: 'very long title', width: 5, }), ); t.snapshot( boxen('foo', { title: 'very long title', width: 20, }), ); }); test('title option with border style (none)', t => { const box = boxen('foo', { title: 'title', borderStyle: 'none', }); t.snapshot(box); }); boxen-7.1.1/tests/width-option.js000066400000000000000000000014251445077726000167760ustar00rootroot00000000000000import test from 'ava'; import boxen from '../index.js'; test('width option works', t => { // Creates a wide box for little text t.snapshot( boxen('foo', { width: 20, }), ); // Creates a small box for a lot of text t.snapshot( boxen('foo bar foo bar', { width: 10, }), ); }); test('width option with padding + margin', t => { // Creates a wide box for little text const box = boxen('foo', { width: 20, margin: 2, padding: 1, }); t.snapshot(box); }); test('width option with big padding', t => { // Should disable the paddings const box = boxen('foo', { width: 6, padding: 3, }); t.snapshot(box); }); test('width option with border style (none)', t => { const box = boxen('foo', { width: 3, borderStyle: 'none', }); t.snapshot(box); });