Repository: sindresorhus/boxen (js)

Issue:
Allow border to be optional.
This tool has a lot of great features for creating boxes, and some of those features would be nice on their own. For instance, fullscreen would be great in some cases even without a border.

My use case, however, incorporates boxen into another utility. In order to achieve "no border", I have given boxen a "ghost border" which I strip after boxen's done working.

```js
borderStyle: {
	topLeft: ' ',
	topRight: ' ',
	bottomLeft: ' ',
	bottomRight: ' ',
	top: ' ',
	bottom: ' ',
	left: ' ',
	right: ' '
}
```

Pull request description:
Allow border to be optional.
Fixes #84

Fix not being able to specify empty strings in borderStyle options.

Patch:
diff --git a/index.d.ts b/index.d.ts
index 289e3dd..570505b 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,5 +1,12 @@
 import {LiteralUnion} from 'type-fest';
-import {BoxStyle, Boxes} from 'cli-boxes';
+import {BoxStyle, Boxes as CLIBoxes} from 'cli-boxes';
+
+/**
+All box styles.
+*/
+interface Boxes extends CLIBoxes {
+	readonly none: BoxStyle;
+}
 
 /**
 Characters used for custom border.
diff --git a/index.js b/index.js
index 70d3e16..9c5e25d 100644
--- a/index.js
+++ b/index.js
@@ -56,6 +56,14 @@ const getBorderChars = borderStyle => {
 
 	let characters;
 
+	// Create empty border style
+	if (borderStyle === 'none') {
+		borderStyle = {};
+		for (const side of sides) {
+			borderStyle[side] = '';
+		}
+	}
+
 	if (typeof borderStyle === 'string') {
 		characters = cliBoxes[borderStyle];
 
@@ -76,7 +84,7 @@ const getBorderChars = borderStyle => {
 		}
 
 		for (const side of sides) {
-			if (!borderStyle[side] || typeof borderStyle[side] !== 'string') {
+			if (borderStyle[side] === null || typeof borderStyle[side] !== 'string') {
 				throw new TypeError(`Invalid border style: ${side}`);
 			}
 		}
diff --git a/readme.md b/readme.md
index aea69ac..547d245 100644
--- a/readme.md
+++ b/readme.md
@@ -116,6 +116,12 @@ Values:
 ↘↓↓↓↙
 →foo←
 ↗↑↑↑↖
+```
+- `'none'`
+```
+
+foo
+
 ```
 
 Style of the box border.


Test patch:
diff --git a/tests/border-option.js b/tests/border-option.js
index 4bd4b39..5c7f30f 100644
--- a/tests/border-option.js
+++ b/tests/border-option.js
@@ -105,6 +105,14 @@ test('border style (round)', t => {
 	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: {
diff --git a/tests/snapshots/tests/border-option.js.md b/tests/snapshots/tests/border-option.js.md
index b2e84d7..33203d8 100644
--- a/tests/snapshots/tests/border-option.js.md
+++ b/tests/snapshots/tests/border-option.js.md
@@ -100,6 +100,14 @@ Generated by [AVA](https://avajs.dev).
     │foo│␊
     ╰───╯`
 
+## border style (none)
+
+> Snapshot 1
+
+    `␊
+    foo␊
+    `
+
 ## border style (custom ascii style)
 
 > Snapshot 1