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

Different behavior of scan method depending on options #62

Open
mrmlnc opened this issue Jan 26, 2020 · 1 comment
Open

Different behavior of scan method depending on options #62

mrmlnc opened this issue Jan 26, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mrmlnc
Copy link
Contributor

mrmlnc commented Jan 26, 2020

Description

The scan method returns different parts depending on options.

  • When the parts option is passed, then */c will be represented as two parts of the pattern (['*', 'c']).
  • When the tokens option is passed, the */c will be represented as one part of the pattern (['*/c']).

The documentation says that the tokens option automatically enables the parts option. Based on this, i expect the behavior to be same when I pass the parts option manually.

parts
This is automatically enabled when options.tokens is true.

Code

const mm = require('micromatch');

const a = mm.scan('a/b/*/c', { parts: true });

console.dir(a.parts, { colors: true });
// [ 'a', 'b', '*', 'c' ]

const b = mm.scan('a/b/*/c', { tokens: true });

console.dir(b.parts, { colors: true });
// [ 'a', 'b', '*/c' ]
@jonschlinkert
Copy link
Member

Based on this, i expect the behavior to be same when I pass the parts option manually.

agreed, that's a bug. I think I might have fixed this already, I'm traveling this weekend. I'll push up a fix ASAP.

@jonschlinkert jonschlinkert added the bug Something isn't working label Jan 26, 2020
@jonschlinkert jonschlinkert self-assigned this Jan 26, 2020
jonschlinkert added a commit that referenced this issue Feb 23, 2020
as well as a few other minor optimizations and linting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants