Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Changed: console.dir() to bypass inspect() methods #2717

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/console.js
Expand Up @@ -38,7 +38,7 @@ exports.error = exports.warn;


exports.dir = function(object) {
process.stdout.write(util.inspect(object) + '\n');
process.stdout.write(util.inspect(object, null, null, null, true) + '\n');
};


Expand Down
6 changes: 4 additions & 2 deletions lib/util.js
Expand Up @@ -91,9 +91,10 @@ var error = exports.error = function(x) {
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
* output. Default is false (no coloring).
*/
function inspect(obj, showHidden, depth, colors) {
function inspect(obj, showHidden, depth, colors, bypassInspect) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 args, haha. Maybe we should start with turning this into an options object.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah haha I was going to but I guess that's for a separate patch

var ctx = {
showHidden: showHidden,
bypassInspect: bypassInspect,
seen: [],
stylize: colors ? stylizeWithColor : stylizeNoColor
};
Expand Down Expand Up @@ -157,7 +158,8 @@ function formatValue(ctx, value, recurseTimes) {
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
!(value.constructor && value.constructor.prototype === value) &&
!ctx.bypassInspect) {
return value.inspect(recurseTimes);
}

Expand Down