From 73b9dd4ac2dbe99d74c7c3cf93fe6d9a57e93b9c Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 27 May 2023 14:41:00 +1200 Subject: [PATCH] feat: add default width to Deno implementation --- deno.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deno.ts b/deno.ts index a94e49f..e768925 100644 --- a/deno.ts +++ b/deno.ts @@ -1,10 +1,19 @@ +/* global Deno */ + // Bootstrap cliui with CommonJS dependencies: import { cliui, UI } from './build/lib/index.js' import type { UIOptions } from './build/lib/index.d.ts' import { wrap, stripAnsi } from './build/lib/string-utils.js' export default function ui (opts: UIOptions): UI { - return cliui(opts, { + const optsWithWidth = opts ?? {} + if (!optsWithWidth.width) { + const { columns } = Deno.consoleSize() + if (columns) { + optsWithWidth.width = columns + } + } + return cliui(optsWithWidth, { stringWidth: (str: string) => { return [...str].length },