Throw errors for users of 'ignore'/'only' options are passed in, but the filename is unknown.

This commit is contained in:
Logan Smyth
2017-12-22 14:21:17 -08:00
parent c292140254
commit a76709cabc

View File

@@ -517,11 +517,14 @@ function shouldIgnore(
only: ?IgnoreList,
dirname: string,
): boolean {
if (context.filename === null) return false;
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
if (ignore) {
if (context.filename === null) {
throw new Error(
`Configuration contains ignore checks, but no filename was passed to Babel`,
);
}
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
if (matchesPatterns(ctx, ignore, dirname)) {
debug(
"Ignored %o because it matched one of %O from %o",
@@ -534,6 +537,14 @@ function shouldIgnore(
}
if (only) {
if (context.filename === null) {
throw new Error(
`Configuration contains ignore checks, but no filename was passed to Babel`,
);
}
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
if (!matchesPatterns(ctx, only, dirname)) {
debug(
"Ignored %o because it failed to match one of %O from %o",