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

Given example of .some not working as expected in v4.0.2 #177

Open
Mark1626 opened this issue Aug 15, 2019 · 2 comments
Open

Given example of .some not working as expected in v4.0.2 #177

Mark1626 opened this issue Aug 15, 2019 · 2 comments

Comments

@Mark1626
Copy link

Mark1626 commented Aug 15, 2019

Please describe the minimum necessary steps to reproduce this issue:

The example given in README for API some is not working as intended.
Link to example in REPL

const mm = require('micromatch');
// mm.some(list, patterns[, options]);

console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
// true
console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
// should be false returning true

What is happening that shouldn't be?

Second case is matching true incorrectly

What should be happening instead?

Second case should match false

Node - v8.16.0
micromatch: "^4.0.2"
@Mark1626
Copy link
Author

Seems to be working fine till ^3.1.10

@Mark1626
Copy link
Author

Mark1626 commented Aug 19, 2019

@jonschlinkert I did some analysis. If I change the order of the patterns it works

Seems to be because of the following code

micromatch/index.js

Lines 259 to 268 in f61212a

micromatch.some = (list, patterns, options) => {
let items = [].concat(list);
for (let pattern of [].concat(patterns)) {
let isMatch = picomatch(String(pattern), options);
if (items.some(item => isMatch(item))) {
return true;
}
}
return false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant