简体   繁体   中英

pattern matching standards (eg .gitignore)

I've worked with a bunch of different tools that have the intention of searching a codebase for files of some type or another and then performing operations on files within. Test libs that find all the files that need to be executed for example. Or the prototypical example is git, which does all kinds of things with all the files in it's project directory.

Most of these products have an equivalent of.gitignore, which has a pattern matching system to make it relatively easy to define which files or subdirectories in a certain directory will be processed vs which would would not.

The pattern matching is simpler than regex (which I assume is good because regex would be overkill) and I'm guessing one of the advantages of the simpler pattern matcher is that it is faster? It makes sense that since every file or directory being crawled in the directory structure needs to be checked against every possible pattern match in the ignore file.

I have a TypeScript project where I want to do a similar type of processing of many files in a directory tree. To crawl the directories I'm currently using fdir https://github.com/thecodrr/fdir . The question is, is there a name for the.gitignore style pattern matching language? Is there libraries for Typescript or Javascript I can use to implement this pattern matching the the maximum possible performance?

https://www.npmjs.com/package/ignore seems to be a very common library for this. 48M weekly downloads, used by eslint so you're probably in good company.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM