Skip to content

Commit

Permalink
Require Node.js 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 13, 2022
1 parent d6b4b32 commit c393023
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
- 14
- 12
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const BORDERS_WIDTH = 2;
const terminalColumns = () => {
const {env, stdout, stderr} = process;

if (stdout && stdout.columns) {
if (stdout?.columns) {
return stdout.columns;
}

if (stderr && stderr.columns) {
if (stderr?.columns) {
return stderr.columns;
}

Expand Down Expand Up @@ -64,13 +64,13 @@ const getBorderChars = borderStyle => {
}
} else {
// Ensure retro-compatibility
if (borderStyle.vertical && typeof borderStyle.vertical === 'string') {
if (typeof borderStyle?.vertical === 'string') {
borderStyle.left = borderStyle.vertical;
borderStyle.right = borderStyle.vertical;
}

// Ensure retro-compatibility
if (borderStyle.horizontal && typeof borderStyle.horizontal === 'string') {
if (typeof borderStyle?.horizontal === 'string') {
borderStyle.top = borderStyle.horizontal;
borderStyle.bottom = borderStyle.horizontal;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ const boxContent = (content, contentWidth, options) => {

const sanitizeOptions = options => {
// If fullscreen is enabled, max-out unspecified width/height
if (options.fullscreen && process && process.stdout) {
if (options.fullscreen && process?.stdout) {
let newDimensions = [process.stdout.columns, process.stdout.rows];

if (typeof options.fullscreen === 'function') {
Expand Down Expand Up @@ -320,7 +320,7 @@ const determineDimensions = (text, options) => {
};

const isHex = color => color.match(/^#(?:[0-f]{3}){1,2}$/i);
const isColorValid = color => typeof color === 'string' && ((chalk[color]) || isHex(color));
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])];

Expand Down Expand Up @@ -358,4 +358,4 @@ export default function boxen(text, options) {
return boxContent(text, options.width, options);
}

export const _borderStyles = cliBoxes;
export {default as _borderStyles} from 'cli-boxes';
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "module",
"exports": "./index.js",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
"node": ">=14.16"
},
"scripts": {
"test": "xo && nyc ava && tsd"
Expand All @@ -36,25 +36,25 @@
],
"dependencies": {
"ansi-align": "^3.0.1",
"camelcase": "^6.2.0",
"chalk": "^4.1.2",
"camelcase": "^7.0.0",
"chalk": "^5.0.1",
"cli-boxes": "^3.0.0",
"string-width": "^5.0.1",
"type-fest": "^2.5.0",
"string-width": "^5.1.2",
"type-fest": "^2.13.0",
"widest-line": "^4.0.1",
"wrap-ansi": "^8.0.1"
},
"devDependencies": {
"ava": "^3.15.0",
"ava": "^4.3.0",
"nyc": "^15.1.0",
"tsd": "^0.17.0",
"typescript": "^4.4.3",
"xo": "^0.45.0"
"tsd": "^0.21.0",
"xo": "^0.50.0"
},
"ava": {
"snapshotDir": "tests/snapshots",
"environmentVariables": {
"COLUMNS": "60"
"COLUMNS": "60",
"FORCE_COLOR": "0"
}
}
}
Binary file modified tests/snapshots/tests/background-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/border-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/float-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/fullscreen-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/height-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/main.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/margin-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/padding-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/text-align-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/title-option.js.snap
Binary file not shown.
Binary file modified tests/snapshots/tests/width-option.js.snap
Binary file not shown.

0 comments on commit c393023

Please sign in to comment.