How to use the micromatch.matcher function in micromatch

To help you get started, we’ve selected a few micromatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rollup / plugins / packages / pluginutils / src / createFilter.ts View on Github external
test: (what: string) => {
            // this refactor is a tad overly verbose but makes for easy debugging
            const pattern = getMatcherString(id, resolutionBase);
            const fn = mm.matcher(pattern, { dot: true });
            const result = fn(what);

            return result;
          }
        };
github isiahmeadows / thallium / lib / cli / iterate-glob.js View on Github external
exports.create = function (globs) {
    if (!Array.isArray(globs)) globs = [globs]

    var positives = []
    var negatives = []
    var accumulator = []

    for (var i = 0; i < globs.length; i++) {
        var glob = globs[i]

        if (typeof glob === "string" && glob[0] === "!") {
            // Create Minimatch instances for negative glob patterns
            accumulator.push(micromatch.matcher(resolveGlob(glob)))
        } else if (glob instanceof RegExp) {
            accumulator.push(glob)
        } else {
            positives.push(glob)
            negatives.push(accumulator.slice())
        }
    }

    if (positives.length === 0) {
        throw new Error("Missing positive glob")
    }

    var opts = {
        nodir: true,
        symlinks: {},
        statCache: {},
github yvele / poosh / packages / poosh-core / src / helpers / GlobMatcher.js View on Github external
matchSingle(fileName, pattern) {
    if (!pattern) {
      return false;
    }

    // Cache the micropatch "pattern parsing"
    let isMatch = this.cache[pattern];
    if (!isMatch) {
      isMatch = micromatch.matcher(pattern);
      this.cache[pattern] = isMatch;
    }

    return isMatch(fileName);
  }
github rollup / rollup-pluginutils / src / createFilter.js View on Github external
	const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ).split ( sep ).join( '/' ) ) } );
	include = ensureArray( include ).map( getMatcher );
github Raathigesh / majestic / app / src / core / engine / fileMatcher.ts View on Github external
  const matchers = globs.map(each => micromatch.matcher(each, { dot: true }));
  return (path: string) => {
github micromatch / glob-fs / middleware / unignore.js View on Github external
module.exports = function (pattern, options) {
  var opts = extend({ matchBase: true }, options);
  var isMatch = mm.matcher(pattern, opts);

  return function unignore(file) {
    if (isMatch(file.path)) {
      delete file.exclude;
      file.include = true;
    }
    return file;
  };
};
github verbose / verb / lib / loaders / glob.js View on Github external
function glob(cwd, pattern, res) {
  if (typeof str !== 'string' || typeof pattern !== 'string') {
    throw new Error('verb/loader/glob requires a string.');
  }

  var files = fs.readdirSync(cwd);
  var len = files.length;
  res = res = {};

  var isMatch = mm.matcher(pattern);

  while (len--) {
    var name = files[len];
    var fp = path.join(cwd, name);
    if (fs.statSync(fp).isDirectory()) {
      glob(fp, pattern, res);
    } else if (isMatch(fp)) {
      var ext = path.extname(name);
      var base = path.basename(name, ext);
      res[base] = utils.toVinyl({
        ext: ext,
        dir: cwd,
        path: fp,
        basename: base,
        content: fs.readFileSync(fp),
        data: {}
github sx1989827 / DOClever / Client / node_modules / rollup-pluginutils / src / createFilter.js View on Github external
	const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ) ) } );
	include = ensureArray( include ).map( getMatcher );
github gulpjs / findup-sync / index.js View on Github external
function matchFile(cwd, pattern, opts) {
  var isMatch = mm.matcher(pattern, opts);
  var files = tryReaddirSync(cwd);
  var len = files.length;
  var idx = -1;

  while (++idx < len) {
    var name = files[idx];
    var fp = path.join(cwd, name);
    if (isMatch(name) || isMatch(fp)) {
      return fp;
    }
  }
  return null;
}

micromatch

Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.

MIT
Latest version published 2 years ago

Package Health Score

87 / 100
Full package analysis