Skip to content

Commit

Permalink
refactor: use inspect and update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Feb 19, 2025
1 parent 1c528e9 commit 601334a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,18 @@ class MongoshNodeRepl implements EvaluationListener {
replHistory.slice(1).reverse();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
formattedHistory[util.inspect.custom as any] = (() => {
return formatOutput(
{
// Providing a copy of the history avoids a circular reference.
value: formattedHistory.concat(),
},
{ colors: true, maxArrayLength: Infinity }
);
formattedHistory[util.inspect.custom as any] = ((
depth: number | null,
options: util.InspectOptions,
inspect: typeof util.inspect
) => {
// We pass a copy of the array without the util.inspect.custom set
// to prevent infinite recursion.
return inspect(formattedHistory.concat(), {
...options,
depth,
maxArrayLength: Infinity,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}) as any;
return formattedHistory;
Expand Down

0 comments on commit 601334a

Please sign in to comment.