11import process from 'node:process' ;
22import { PassThrough as PassThroughStream } from 'node:stream' ;
3+ import { stripVTControlCharacters } from 'node:util' ;
34import assert from 'node:assert/strict' ;
45import test from 'node:test' ;
56import getStream from 'get-stream' ;
6- import stripAnsi from 'strip-ansi' ;
77import TransformTTY from 'transform-tty' ;
88import ora , { oraPromise , spinners } from './index.js' ;
99
@@ -35,7 +35,7 @@ const doSpinner = async (function_, extraOptions = {}) => {
3535 function_ ( spinner ) ;
3636 stream . end ( ) ;
3737
38- return stripAnsi ( await output ) ;
38+ return stripVTControlCharacters ( await output ) ;
3939} ;
4040
4141test ( 'main' , async ( ) => {
@@ -186,7 +186,7 @@ test('oraPromise() - resolves', async () => {
186186 await resolves ;
187187 stream . end ( ) ;
188188
189- assert . match ( stripAnsi ( await output ) , / [ √ ✔ ] f o o \n $ / ) ;
189+ assert . match ( stripVTControlCharacters ( await output ) , / [ √ ✔ ] f o o \n $ / ) ;
190190} ) ;
191191
192192test ( 'oraPromise() - rejects' , async ( ) => {
@@ -205,7 +205,7 @@ test('oraPromise() - rejects', async () => {
205205
206206 stream . end ( ) ;
207207
208- assert . match ( stripAnsi ( await output ) , / [ × ✖ ] f o o \n $ / ) ;
208+ assert . match ( stripVTControlCharacters ( await output ) , / [ × ✖ ] f o o \n $ / ) ;
209209} ) ;
210210
211211test ( 'erases wrapped lines' , ( ) => {
@@ -322,7 +322,7 @@ test('reset frameIndex when setting new spinner', async () => {
322322 stream . end ( ) ;
323323
324324 assert . strictEqual ( spinner . _frameIndex , 0 ) ;
325- assert . match ( stripAnsi ( await output ) , / f o o b a z / ) ;
325+ assert . match ( stripVTControlCharacters ( await output ) , / f o o b a z / ) ;
326326} ) ;
327327
328328test ( 'set the correct interval when changing spinner (object case)' , ( ) => {
@@ -590,7 +590,7 @@ test('oraPromise(function) passes spinner and supports successText function', as
590590 } ) ;
591591
592592 stream . end ( ) ;
593- assert . match ( stripAnsi ( await output ) , / [ √ ✔ ] d o n e : 7 \n $ / ) ;
593+ assert . match ( stripVTControlCharacters ( await output ) , / [ √ ✔ ] d o n e : 7 \n $ / ) ;
594594} ) ;
595595
596596test ( 'oraPromise(function) rejects and supports failText function' , async ( ) => {
@@ -611,7 +611,7 @@ test('oraPromise(function) rejects and supports failText function', async () =>
611611 } catch { }
612612
613613 stream . end ( ) ;
614- assert . match ( stripAnsi ( await output ) , / [ × ✖ ] o o p s : b o o m \n $ / ) ;
614+ assert . match ( stripVTControlCharacters ( await output ) , / [ × ✖ ] o o p s : b o o m \n $ / ) ;
615615} ) ;
616616
617617test ( 'oraPromise() validates `action` type' , async ( ) => {
@@ -710,7 +710,7 @@ test('start() with empty text and isEnabled:false produces no output', async ()
710710 spinner . start ( ) ;
711711 stream . end ( ) ;
712712
713- const text = stripAnsi ( await output ) ;
713+ const text = stripVTControlCharacters ( await output ) ;
714714 assert . match ( text , / ^ (? ! [ \s \S ] ) / ) ;
715715} ) ;
716716
@@ -1495,7 +1495,7 @@ test('disabled spinner preserves prefix/suffix/indent', async () => {
14951495 spinner . start ( ) ;
14961496 stream . end ( ) ;
14971497
1498- const text = stripAnsi ( await output ) ;
1498+ const text = stripVTControlCharacters ( await output ) ;
14991499 assert . strictEqual ( text , ' pre - test post\n' ) ;
15001500} ) ;
15011501
0 commit comments