Skip to content
Permalink
Browse files

Fix: `overrides` handle relative paths as expected (fixes #11577) (#1…

  • Loading branch information...
mysticatea committed Jun 5, 2019
1 parent 5509cdf commit 21f3131aa1636afa8e5c01053e0e870f968425b1
@@ -55,7 +55,17 @@ function toMatcher(patterns) {
if (patterns.length === 0) {
return null;
}
return patterns.map(pattern => new Minimatch(pattern, minimatchOpts));
return patterns.map(pattern => {
if (/^\.[/\\]/u.test(pattern)) {
return new Minimatch(
pattern.slice(2),

// `./*.js` should not match with `subdir/foo.js`
{ ...minimatchOpts, matchBase: false }
);
}
return new Minimatch(pattern, minimatchOpts);
});
}

/**
@@ -191,10 +191,10 @@ describe("OverrideTester", () => {
match("foo.js", ["*.js"], []);
match("foo.js", ["**/*.js"], []);
match("bar.js", ["*.js"], ["foo.js"]);
match("foo.js", ["./foo.js"], []);
match("foo.js", ["./*"], []);
match("foo.js", ["./**"], []);

noMatch("foo.js", ["./foo.js"], []);
noMatch("foo.js", ["./*"], []);
noMatch("foo.js", ["./**"], []);
noMatch("foo.js", ["*"], ["foo.js"]);
noMatch("foo.js", ["*.js"], ["foo.js"]);
noMatch("foo.js", ["**/*.js"], ["foo.js"]);
@@ -208,11 +208,11 @@ describe("OverrideTester", () => {
match("subdir/foo.js", ["subdir/foo.js"], []);
match("subdir/foo.js", ["subdir/*"], []);
match("subdir/second/foo.js", ["subdir/**"], []);
match("subdir/foo.js", ["./**"], []);
match("subdir/foo.js", ["./subdir/**"], []);
match("subdir/foo.js", ["./subdir/*"], []);

noMatch("subdir/foo.js", ["./foo.js"], []);
noMatch("subdir/foo.js", ["./**"], []);
noMatch("subdir/foo.js", ["./subdir/**"], []);
noMatch("subdir/foo.js", ["./subdir/*"], []);
noMatch("subdir/foo.js", ["*"], ["subdir/**"]);
noMatch("subdir/very/deep/foo.js", ["*.js"], ["subdir/**"]);
noMatch("subdir/second/foo.js", ["subdir/*"], []);

0 comments on commit 21f3131

Please sign in to comment.
You can’t perform that action at this time.