Skip to content

Commit 601334a

Browse files
committed
refactor: use inspect and update comment
1 parent 1c528e9 commit 601334a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/cli-repl/src/mongosh-repl.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)