picomatch
picomatch copied to clipboard
Different behavior of scan method depending on options
Description
The scan method returns different parts depending on options.
- When the
partsoption is passed, then*/cwill be represented as two parts of the pattern (['*', 'c']). - When the
tokensoption is passed, the*/cwill 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.
partsThis is automatically enabled whenoptions.tokensistrue.
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' ]
Based on this, i expect the behavior to be same when I pass the
partsoption 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.