Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve debug logging for IgnoreList #13814

Merged
merged 2 commits into from Oct 6, 2021
Merged
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions packages/babel-core/src/config/config-chain.ts
@@ -1,4 +1,5 @@
import path from "path";
import { inspect } from "util";
import buildDebug from "debug";
import type { Handler } from "gensync";
import { validate } from "./validation/options";
Expand Down Expand Up @@ -779,6 +780,20 @@ function configFieldIsApplicable(
return matchesPatterns(context, patterns, dirname);
}

/**
* Print the ignoreList-values in a more helpful way than the default.
*/
function ignoreListReplacer(
_key: string,
value: IgnoreList | IgnoreItem,
): IgnoreList | IgnoreItem | string {
if (value instanceof RegExp) {
return inspect(value);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to use util.inspect:

Suggested change
return inspect(value);
return String(value);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's awesome! I'll fix it

}

return value;
}

/**
* Tests if a filename should be ignored based on "ignore" and "only" options.
*/
Expand All @@ -793,6 +808,7 @@ function shouldIgnore(
context.filename ?? "(unknown)"
}" because it matches one of \`ignore: ${JSON.stringify(
ignore,
ignoreListReplacer,
)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
Expand All @@ -806,6 +822,7 @@ function shouldIgnore(
context.filename ?? "(unknown)"
}" because it fails to match one of \`only: ${JSON.stringify(
only,
ignoreListReplacer,
)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
Expand Down