Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolashenry committed Sep 11, 2019
1 parent 2076154 commit d565409
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
28 changes: 17 additions & 11 deletions index.js
Expand Up @@ -53,10 +53,8 @@ function watch(glob, options, cb) {
var queued = false;
var running = false;

// These use sparse arrays to keep track of the index in the
// original globs array
var positives = new Array(glob.length);
var negatives = new Array(glob.length);
var positives = [];
var negatives = [];

// Reverse the glob here so we don't end up with a positive
// and negative glob in position 0 after a reverse
Expand All @@ -65,26 +63,34 @@ function watch(glob, options, cb) {
function sortGlobs(globString, index) {
var result = isNegatedGlob(globString);
if (result.negated) {
negatives[index] = result.pattern;
negatives.push({ index: index, pattern: result.pattern });
} else {
positives[index] = result.pattern;
positives.push({ index: index, pattern: result.pattern });
}
}

function toPattern(v) {
return v.pattern;
}

function shouldBeIgnored(path) {
var positiveMatch = anymatch(positives, path, true);
var negativeMatch = anymatch(negatives, path, true);
var positiveMatch = anymatch(
positives.map(toPattern), path, { returnIndex: true }
);
var negativeMatch = anymatch(
negatives.map(toPattern), path, { returnIndex: true }
);
// If negativeMatch is -1, that means it was never negated
if (negativeMatch === -1) {
if (negativeMatch === -1 || positiveMatch === -1) {
return false;
}

// If the negative is "less than" the positive, that means
// it came later in the glob array before we reversed them
return negativeMatch < positiveMatch;
return negatives[negativeMatch].index < positives[positiveMatch].index;
}

var toWatch = positives.filter(exists);
var toWatch = positives.map(toPattern).filter(exists);

// We only do add our custom `ignored` if there are some negative globs
// TODO: I'm not sure how to test this
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -21,9 +21,9 @@
"coveralls": "npm run cover && istanbul-coveralls"
},
"dependencies": {
"anymatch": "^2.0.0",
"anymatch": "^3.1.0",
"async-done": "^1.2.0",
"chokidar": "^2.0.0",
"chokidar": "^3.0.0",
"is-negated-glob": "^1.0.0",
"just-debounce": "^1.0.0",
"object.defaults": "^1.1.0"
Expand Down

0 comments on commit d565409

Please sign in to comment.