From 8b03a8ae5177e6d9656296bdd3f8dc140952f9a8 Mon Sep 17 00:00:00 2001 From: Shiv Date: Fri, 17 Oct 2025 12:43:24 +0100 Subject: [PATCH] Refactor string-width import for Bun compatibility Conditionally require 'string-width' based on Bun availability. --- lib/formatter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/formatter.js b/lib/formatter.js index 8ca662d..1155645 100644 --- a/lib/formatter.js +++ b/lib/formatter.js @@ -1,7 +1,13 @@ -const _stringWidth = require('string-width'); const _defaultFormatValue = require('./format-value'); const _defaultFormatBar = require('./format-bar'); const _defaultFormatTime = require('./format-time'); +let _stringWidth; + +if (typeof Bun !== 'undefined') { + _stringWidth = Bun.stringWidth; +} else { + _stringWidth = require('string-width'); +} // generic formatter module.exports = function defaultFormatter(options, params, payload){