picomatch icon indicating copy to clipboard operation
picomatch copied to clipboard

Different behavior of scan method depending on options

Open mrmlnc opened this issue 5 years ago • 1 comments

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' ]

mrmlnc avatar Jan 26 '20 11:01 mrmlnc

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 avatar Jan 26 '20 16:01 jonschlinkert