Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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