Skip to content

Commit 1a45f93

Browse files
authored
chore: use fast-wrap-ansi (#366)
1 parent db8e5a4 commit 1a45f93

File tree

6 files changed

+39
-64
lines changed

6 files changed

+39
-64
lines changed

.changeset/light-waves-jog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@clack/prompts": patch
3+
"@clack/core": patch
4+
---
5+
6+
Switched from wrap-ansi to fast-wrap-ansi

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@
5858
},
5959
"devDependencies": {
6060
"vitest": "^3.2.4",
61-
"wrap-ansi": "^8.1.0"
61+
"fast-wrap-ansi": "^0.1.3"
6262
}
6363
}

packages/core/src/prompts/prompt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { stdin, stdout } from 'node:process';
22
import readline, { type Key, type ReadLine } from 'node:readline';
33
import type { Readable, Writable } from 'node:stream';
4+
import { wrapAnsi } from 'fast-wrap-ansi';
45
import { cursor, erase } from 'sisteransi';
5-
import wrap from 'wrap-ansi';
66
import type { ClackEvents, ClackState } from '../types.js';
77
import type { Action } from '../utils/index.js';
88
import { CANCEL_SYMBOL, diffLines, isActionKey, setRawMode, settings } from '../utils/index.js';
@@ -253,13 +253,13 @@ export default class Prompt<TValue> {
253253

254254
private restoreCursor() {
255255
const lines =
256-
wrap(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split('\n')
256+
wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split('\n')
257257
.length - 1;
258258
this.output.write(cursor.move(-999, lines * -1));
259259
}
260260

261261
private render() {
262-
const frame = wrap(this._render(this) ?? '', process.stdout.columns, {
262+
const frame = wrapAnsi(this._render(this) ?? '', process.stdout.columns, {
263263
hard: true,
264264
trim: false,
265265
});

packages/prompts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"memfs": "^4.17.2",
6363
"vitest": "^3.2.4",
6464
"vitest-ansi-serializer": "^0.1.2",
65-
"wrap-ansi": "^8.1.0"
65+
"fast-wrap-ansi": "^0.1.3"
6666
}
6767
}

packages/prompts/src/spinner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { block, getColumns, settings } from '@clack/core';
2+
import { wrapAnsi } from 'fast-wrap-ansi';
23
import color from 'picocolors';
34
import { cursor, erase } from 'sisteransi';
4-
import wrap from 'wrap-ansi';
55
import {
66
type CommonOptions,
77
isCI as isCIFn,
@@ -96,7 +96,7 @@ export const spinner = ({
9696
const clearPrevMessage = () => {
9797
if (_prevMessage === undefined) return;
9898
if (isCI) output.write('\n');
99-
const wrapped = wrap(_prevMessage, columns, {
99+
const wrapped = wrapAnsi(_prevMessage, columns, {
100100
hard: true,
101101
trim: false,
102102
});
@@ -144,7 +144,7 @@ export const spinner = ({
144144
outputMessage = `${frame} ${_message}${loadingDots}`;
145145
}
146146

147-
const wrapped = wrap(outputMessage, columns, {
147+
const wrapped = wrapAnsi(outputMessage, columns, {
148148
hard: true,
149149
trim: false,
150150
});

pnpm-lock.yaml

Lines changed: 25 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)