-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
use case is that, first new a matcher in anymatch, 2nd use the matcher to match teststring.
if teststring is path string and some path or file has dot symbol, will match failed, the example at flow:
const matcher = anymatch(["**/node_modules/**"]);
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
const result = matcher(str); // false
const result2 = matcher(str2); // falsethen i review the source code of anymatch, and i found a solution:
const matcher = anymatch(["**/node_modules/**"], null, {dot: true});
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
const result = matcher(str); // true // ts checker error
const result2 = matcher(str2); // true // ts checker errorbut if this code is in ts, the ide tell me an error of checker at the line that match the test string, because anymatch/index.d.ts dosn't have this override, so we should add a comment to tell checker to ignore this line.
const matcher = anymatch(["**/node_modules/**"], null, {dot: true});
const str = "abs/node_modules/.path/file.js";
const str2 = "abs/node_modules/.file.js";
// @ts-ignore
const result = matcher(str); // true
// @ts-ignore
const result2 = matcher(str2); // trueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels