File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed
Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import type { Duplex } from 'stream';
1010import { PassThrough } from 'stream' ;
1111import type { StubbedInstance } from 'ts-sinon' ;
1212import { stubInterface } from 'ts-sinon' ;
13- import { promisify } from 'util' ;
13+ import { inspect , promisify } from 'util' ;
1414import {
1515 expect ,
1616 fakeTTYProps ,
@@ -547,13 +547,11 @@ describe('MongoshNodeRepl', function () {
547547 input . write ( 'history()\n' ) ;
548548 await waitEval ( bus ) ;
549549 expect ( output ) . includes (
550- formatOutput (
551- {
552- value : getAllHistoryItems ( )
553- . slice ( 1 , getAllHistoryItems ( ) . length )
554- . reverse ( ) ,
555- } ,
556- { colors : true , maxArrayLength : Infinity }
550+ inspect (
551+ getAllHistoryItems ( )
552+ . slice ( 1 , getAllHistoryItems ( ) . length )
553+ . reverse ( ) ,
554+ { maxArrayLength : Infinity }
557555 )
558556 ) ;
559557 } ) ;
Original file line number Diff line number Diff line change @@ -403,14 +403,18 @@ class MongoshNodeRepl implements EvaluationListener {
403403 replHistory . slice ( 1 ) . reverse ( ) ;
404404
405405 // eslint-disable-next-line @typescript-eslint/no-explicit-any
406- formattedHistory [ util . inspect . custom as any ] = ( ( ) => {
407- return formatOutput (
408- {
409- // Providing a copy of the history avoids a circular reference.
410- value : formattedHistory . concat ( ) ,
411- } ,
412- { colors : true , maxArrayLength : Infinity }
413- ) ;
406+ formattedHistory [ util . inspect . custom as any ] = ( (
407+ depth : number | null ,
408+ options : util . InspectOptions ,
409+ inspect : typeof util . inspect
410+ ) => {
411+ // We pass a copy of the array without the util.inspect.custom set
412+ // to prevent infinite recursion.
413+ return inspect ( formattedHistory . concat ( ) , {
414+ ...options ,
415+ depth,
416+ maxArrayLength : Infinity ,
417+ } ) ;
414418 // eslint-disable-next-line @typescript-eslint/no-explicit-any
415419 } ) as any ;
416420 return formattedHistory ;
You can’t perform that action at this time.
0 commit comments