Skip to content

Commit

Permalink
Use micromatch and bump anymatch. (#115)
Browse files Browse the repository at this point in the history
* Use `micromatch` and bump `anymatch`.

* Update `README.md`, remove `minimatch`.
  • Loading branch information
wtgtybhertgeghgtwtg authored and stefanpenner committed Mar 16, 2018
1 parent ec657e4 commit a419f94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -55,7 +55,7 @@ options:
* `dot`: enables watching files/directories that start with a dot.
* `ignored`: a glob, regex, function, or array of any combination.

For the glob pattern documentation, see [minimatch](https://github.com/isaacs/minimatch).
For the glob pattern documentation, see [micromatch](https://github.com/micromatch/micromatch).
If you choose to use `watchman` you'll have to [install watchman yourself](https://facebook.github.io/watchman/docs/install.html)).
For the ignored options, see [anymatch](https://github.com/es128/anymatch).

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -28,10 +28,10 @@
"author": "amasad",
"license": "MIT",
"dependencies": {
"anymatch": "^1.3.0",
"anymatch": "^2.0.0",
"exec-sh": "^0.2.0",
"fb-watchman": "^2.0.0",
"minimatch": "^3.0.2",
"micromatch": "^3.1.4",
"minimist": "^1.1.1",
"walker": "~1.0.5",
"watch": "~0.18.0"
Expand Down
23 changes: 6 additions & 17 deletions src/common.js
Expand Up @@ -2,7 +2,7 @@

var walker = require('walker');
var anymatch = require('anymatch');
var minimatch = require('minimatch');
var micromatch = require('micromatch');
var path = require('path');
var platform = require('os').platform();

Expand Down Expand Up @@ -59,23 +59,12 @@ exports.assignOptions = function(watcher, opts) {
*/

exports.isFileIncluded = function(globs, dot, doIgnore, relativePath) {
var matched;
if (globs.length) {
for (var i = 0; i < globs.length; i++) {
if (
minimatch(relativePath, globs[i], { dot: dot }) &&
!doIgnore(relativePath)
) {
matched = true;
break;
}
}
} else {
// Make sure we honor the dot option if even we're not using globs.
matched =
(dot || minimatch(relativePath, '**/*')) && !doIgnore(relativePath);
if (doIgnore(relativePath)) {
return false;
}
return matched;
return globs.length
? micromatch.some(relativePath, globs, { dot: dot })
: dot || micromatch.some(relativePath, '**/*');
};

/**
Expand Down

0 comments on commit a419f94

Please sign in to comment.