How to use the capture function from micromatch

Find comprehensive JavaScript micromatch.capture code examples handpicked from public code repositorys.

68
69
70
71
72
73
74
75
76
for (const [folderPattern, namingPattern] of Object.entries(rules)) {
  if (!micromatch.isMatch(path, folderPattern)) {
    continue;
  } else {
    const matchedPaths =
      micromatch.capture(folderPattern, path) || [];
    const folders = matchedPaths
      .filter(isNotEmpty)
      .reduce((s, p) => s.concat(getAllFolders(p)), []);
fork icon8
star icon49
watch icon0

7
8
9
10
11
12
13
14
15
16
17
 * @param {Array} ruleset.1 rule to transform
 * @param {string} filenameWithPath filename with path
 * @returns {Array} [glob, rule]
 */
function transformRuleWithGroupCapture([glob, rule], filenameWithPath) {
  const keyCaptureGroups = micromatch.capture(glob, filenameWithPath);


  if (!keyCaptureGroups) {
    return [glob, rule];
  }
fork icon8
star icon39
watch icon1

+ 2 other calls in file

112
113
114
115
116
117
118
119
120
121
122
123
  return message
}


const useOrAddCanvasPackage = (error) => {
  const { target } = error
  const [packageName] = micromatch.capture('ui/shared/*/**', target) || []
  const [pjsonFile, pjson] = t.findPackageJSON(target, [`@canvas/${packageName}`]) || []


  if (pjsonFile) {
    return useExistingPackage(error, { pjsonFile, pjson })
fork icon0
star icon0
watch icon0