match-file
Returns true when the given
name
matches any of the path properties on a vinyl file.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.
Install
Install with npm:
$ npm install --save match-file
Usage
var matchFile = ;
API
matchFile
Returns true if the given string matches one of the path properties on the file
object (does not match agains file.extname
only)
var File = ;var matchFile = ; var file = path: 'a/b/c.txt' base: 'a';var isMatch = ;//=> true (since `c.txt` matches file.basename)
Examples
Continuing with the above setup code, all of the following would return true
:
// file.path;// file.relative;// file.basename;// file.stem;
.isMatch
Similar to matchFile
, but also supports glob patterns for matching. micromatch is used for matching, visit that project to see all available features and options.
var file = path: 'a/b/c.txt';console;//=> false var file = path: 'a/b/c.js';console;//=> true
Examples
var File = ;var matchFile = ; var file = path: 'a/b/c/d/e.txt' base: 'a/b/c';filekey = 'zzz/a.txt'; // arbitrary key (for caching)
// file.pathconsole;// file.relativeconsole;// file.basenameconsole;// file.stemconsole;// file.keyconsole;// glob pattern for `file.path`console;// glob pattern for `file.relative`console;// glob pattern for `file.stem`console;// glob pattern for `file.basename`console;
.matcher
Returns a matcher function bound to the given glob patterns
and options
. micromatch is used for matching, visit that project to see all available features and options.
var isMatch = matchFile;console;//=> [function] var file = path: 'a/b/c.txt';console;//=> false var file = path: 'a/b/c.js';console;//=> true
Examples
Given this setup code:
var File = ;var matchFile = ; var file = path: 'a/b/c/d/e.txt' base: 'a/b/c';filekey = 'zzz/a.txt'; // arbitrary key (for caching)
All of the following examples would return true
:
// file.pathvar isMatch = matchFile;console;// file.relativevar isMatch = matchFile;console;// file.basenamevar isMatch = matchFile;console;// file.stemvar isMatch = matchFile;console;// file.keyvar isMatch = matchFile;console;// glob pattern for `file.path`var isMatch = matchFile;console;// glob pattern for `file.relative`var isMatch = matchFile;console;// glob pattern for `file.stem`var isMatch = matchFile;console;// glob pattern for `file.basename`var isMatch = matchFile;console;
Gulp usage
Use in your gulp plugin:
var though = ;var gulp = ; gulp; { // define a matcher function outside of the plugin function var isMatch = matchFile; return through;}
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Related projects
You might also be interested in these projects:
- assemble: Get the rocks out of your socks! Assemble makes you fast at creating web projects… more | homepage
- generate: Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… more | homepage
- get-view: Utility for getting an assemble view from a collection object. | homepage
- micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | homepage
- verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage
Author
Jon Schlinkert
License
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on February 14, 2018.