How to use the micromatch.match 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 thumbsup / thumbsup / test / components / index / glob.spec.js View on Github external
it('bootstraps micromatch', () => {
    // This is a workaround for https://github.com/tschaub/mock-fs/issues/213
    // Because micromatch() loads packages dynamically which doesn't work if the filesystem is being mocked
    // So we need to pre-load them now
    require('micromatch').match('file.txt', '**/**')
  })
github static-dev / spike-core / lib / plugins / experimental_iso_plugin.js View on Github external
compiler.plugin('make', (compilation, done) => {
      jadeFiles = compiler.options.spike.files.jade
      // get paths relative to root
      const filesRelative = jadeFiles.map((f) => {
        return f.replace(this.opts.root + '/', '')
      })
      // filter in files matching the user-defined matcher
      const matchingFiles = mm.match(filesRelative, this.files)

      // now we are going to build the link injector script
      let mod = ''

      // first, we require in all the matching jade files so that we have the
      // contents ready to inject if needed
      matchingFiles.map((f) => {
        mod += `exports.${path.basename(f, '.jade')} = require('../${f}')\n`
      })

      // now we add the script that matches link clicks to templates
      mod += `
        const links = querySelectorAll('a')
        links.map((l) => {
          l.onclick = (e) => {
            e.preventDefault()
github saojs / kopy / src / move-files.js View on Github external
return ctx => {
    if (typeof move === 'function') {
      move = move(ctx.meta.merged)
    }

    if (!move) return

    for (const pattern in move) {
      const matches = match.match(ctx.fileList, pattern)
      if (matches.length > 0) {
        const newName = move[pattern]
        if (typeof newName === 'function') {
          for (const match of matches) {
            const file = ctx.file(match)
            const fileName = newName(match)
            // eslint-disable-next-line max-depth
            if (fileName) {
              ctx.deleteFile(match)
              ctx.createFile(fileName, file)
            }
          }
        } else if (typeof newName === 'string') {
          const file = ctx.file(matches[0])
          ctx.deleteFile(matches[0])
          ctx.createFile(newName, file)
github doowb / composer / lib / resolve.js View on Github external
const options = args.find(arg => typeOf(arg) === 'object') || {};
  const tasks = [];

  for (const val of args) {
    if (val === options) {
      continue;
    }

    const type = typeOf(val);
    switch (type) {
      case 'function':
        tasks.push(val);
        continue;
      case 'string':
        if (isGlob(val) && !/\[anonymous \(\d*\)\]/.test(val)) {
          const matches = mm.match(names, val);

          if (!matches.length) {
            throw new Error('glob pattern "' + val + '" does not match any registered tasks');
          }

          for (const name of matches) {
            tasks.push(resolveTask(this.tasks, name, options));
          }
        } else {
          tasks.push(resolveTask(this.tasks, val, options));
        }
        break;
      default: {
        throw new TypeError(`task argument type "${type}" is not supported`);
      }
    }
github danger / danger-js / source / commands / utils / chainsmoker.ts View on Github external
      return excludePatterns.reduce((accum, pattern) => micromatch.match(accum, pattern), included)
    }) as KeyedPaths
github danger / danger-js / source / commands / utils / chainsmoker.ts View on Github external
        (accum, pattern) => accum.concat(micromatch.match(paths, pattern)),
        [] as Path[]
github lint-deps / lint-deps / index.js View on Github external
return depTypes(types).reduce(function(acc, type) {
      var keys = depsKeys(pkg, type);
      var res = mm.match(keys, pattern || '*');
      return acc.concat(res);
    }, []);
  };
github opentable / mercury / src / translations / get-list.js View on Github external
_.each(srcGlobs.src, glob => {
      result = mm.match(result, glob);
    });
github jonschlinkert / template-helpers / lib / glob.js View on Github external
exports.match = function match(fp, pattern, options) {
  return mm.match(fp, pattern, options);
};

micromatch

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

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis