diff --git a/CHANGELOG.md b/CHANGELOG.md index a49acf80..e8534881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## v3.2.2 + +[compare changes](https://github.com/unjs/consola/compare/v3.2.1...v3.2.2) + + +### 🩹 Fixes + + - **fancy:** Add node 14 compatibility ([#204](https://github.com/unjs/consola/pull/204)) + +### 📦 Build + + - **pkg:** Add supported engines field ([#179](https://github.com/unjs/consola/pull/179)) + +### ❤️ Contributors + +- Pooya Parsa ([@pi0](http://github.com/pi0)) + ## v3.2.1 [compare changes](https://github.com/unjs/consola/compare/v3.2.0...v3.2.1) diff --git a/package.json b/package.json index f92cee14..7f028603 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "consola", - "version": "3.2.1", + "version": "3.2.2", "description": "Elegant Console Wrapper", "keywords": [ "console", @@ -94,5 +94,8 @@ "unbuild": "^1.2.1", "vitest": "^0.32.2" }, + "engines": { + "node": "^14.18.0 || >=16.10.0" + }, "packageManager": "pnpm@8.6.5" } \ No newline at end of file diff --git a/src/reporters/fancy.ts b/src/reporters/fancy.ts index ae9e19ce..9a60642c 100644 --- a/src/reporters/fancy.ts +++ b/src/reporters/fancy.ts @@ -1,10 +1,11 @@ -import stringWidth from "string-width"; +import _stringWidth from "string-width"; import isUnicodeSupported from "is-unicode-supported"; import { colors } from "../utils/color"; import { parseStack } from "../utils/error"; import { FormatOptions, LogObject } from "../types"; import { LogLevel, LogType } from "../constants"; import { BoxOpts, box } from "../utils/box"; +import { stripAnsi } from "../utils"; import { BasicReporter } from "./basic"; export const TYPE_COLOR_MAP: { [k in LogType]?: string } = { @@ -36,6 +37,14 @@ const TYPE_ICONS: { [k in LogType]?: string } = { log: "", }; +function stringWidth(str: string) { + // https://github.com/unjs/consola/issues/204 + if (!Intl.Segmenter) { + return stripAnsi(str).length; + } + return _stringWidth(str); +} + export class FancyReporter extends BasicReporter { formatStack(stack: string) { return (