Socket
Socket
Sign inDemoInstall

boxen

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 2.0.0

23

index.js

@@ -63,3 +63,6 @@ 'use strict';

const getBackgroundColorName = x => camelCase('bg', x);
const isHex = color => color.match(/^#[0-f]{3}(?:[0-f]{3})?$/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])];

@@ -75,11 +78,7 @@ module.exports = (text, opts) => {

if (opts.backgroundColor) {
opts.backgroundColor = getBackgroundColorName(opts.backgroundColor);
}
if (opts.borderColor && !chalk[opts.borderColor]) {
if (opts.borderColor && !isColorValid(opts.borderColor)) {
throw new Error(`${opts.borderColor} is not a valid borderColor`);
}
if (opts.backgroundColor && !chalk[opts.backgroundColor]) {
if (opts.backgroundColor && !isColorValid(opts.backgroundColor)) {
throw new Error(`${opts.backgroundColor} is not a valid backgroundColor`);

@@ -93,7 +92,7 @@ }

const colorizeBorder = x => {
const ret = opts.borderColor ? chalk[opts.borderColor](x) : x;
const ret = opts.borderColor ? getColorFn(opts.borderColor)(x) : x;
return opts.dimBorder ? chalk.dim(ret) : ret;
};
const colorizeContent = x => opts.backgroundColor ? chalk[opts.backgroundColor](x) : x;
const colorizeContent = x => opts.backgroundColor ? getBGColorFn(opts.backgroundColor)(x) : x;

@@ -108,7 +107,7 @@ text = ansiAlign(text, {align: opts.align});

if (padding.top > 0) {
lines = Array(padding.top).fill('').concat(lines);
lines = new Array(padding.top).fill('').concat(lines);
}
if (padding.bottom > 0) {
lines = lines.concat(Array(padding.bottom).fill(''));
lines = lines.concat(new Array(padding.bottom).fill(''));
}

@@ -118,3 +117,3 @@

const paddingLeft = PAD.repeat(padding.left);
const columns = termSize().columns;
const {columns} = termSize();
let marginLeft = PAD.repeat(margin.left);

@@ -121,0 +120,0 @@

{
"name": "boxen",
"version": "1.3.0",
"description": "Create boxes in the terminal",
"license": "MIT",
"repository": "sindresorhus/boxen",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js"
],
"keywords": [
"cli",
"box",
"boxes",
"terminal",
"term",
"console",
"ascii",
"unicode",
"border",
"text"
],
"dependencies": {
"ansi-align": "^2.0.0",
"camelcase": "^4.0.0",
"chalk": "^2.0.1",
"cli-boxes": "^1.0.0",
"string-width": "^2.0.0",
"term-size": "^1.2.0",
"widest-line": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"nyc": "^11.0.3",
"xo": "*"
}
"name": "boxen",
"version": "2.0.0",
"description": "Create boxes in the terminal",
"license": "MIT",
"repository": "sindresorhus/boxen",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js"
],
"keywords": [
"cli",
"box",
"boxes",
"terminal",
"term",
"console",
"ascii",
"unicode",
"border",
"text"
],
"dependencies": {
"ansi-align": "^2.0.0",
"camelcase": "^5.0.0",
"chalk": "^2.4.1",
"cli-boxes": "^1.0.0",
"string-width": "^2.1.1",
"term-size": "^1.2.0",
"widest-line": "^2.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"nyc": "^13.0.1",
"xo": "^0.23.0"
}
}

@@ -1,6 +0,6 @@

# <img src="screenshot.png" width="400" alt="boxen">
# boxen [![Build Status](https://travis-ci.org/sindresorhus/boxen.svg?branch=master)](https://travis-ci.org/sindresorhus/boxen)
> Create boxes in the terminal
[![Build Status](https://travis-ci.org/sindresorhus/boxen.svg?branch=master)](https://travis-ci.org/sindresorhus/boxen)
![](screenshot.png)

@@ -14,3 +14,7 @@

<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>
## Usage

@@ -55,6 +59,8 @@

Type: `Object`
##### borderColor
Type: `string`<br>
Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray`
Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray` or a hex value like `#ff0000`

@@ -155,4 +161,4 @@ Color of the box border.

Type: `string`<br>
Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white`
Type: `string`
Values: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray` or a hex value like `#ff0000`

@@ -174,2 +180,3 @@ Color of the background.

- [cli-boxes](https://github.com/sindresorhus/cli-boxes) - Boxes for use in the terminal
- [ink-box](https://github.com/sindresorhus/ink-box) - Box component for Ink that uses this package

@@ -176,0 +183,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc