How to use the micromatch.makeRe 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 parcel-bundler / parcel / packages / resolvers / default / src / DefaultResolver.js View on Github external
lookupAlias(aliases, filename, dir) {
    // First, try looking up the exact filename
    let alias = aliases[filename];
    if (alias == null) {
      // Otherwise, try replacing glob keys
      for (let key in aliases) {
        let val = aliases[key];
        if (typeof val === 'string' && isGlob(key)) {
          let re = micromatch.makeRe(key, {capture: true});
          if (re.test(filename)) {
            alias = filename.replace(re, val);
            break;
          }
        }
      }
    }

    if (typeof alias === 'string') {
      return this.resolveFilename(alias, dir);
    }

    return typeof alias === 'string' ? alias : null;
  }
github parcel-bundler / parcel / packages / resolvers / default / src / DefaultResolver.js View on Github external
lookupAlias(aliases, filename, dir) {
    // First, try looking up the exact filename
    let alias = aliases[filename];
    if (alias == null) {
      // Otherwise, try replacing glob keys
      for (let key in aliases) {
        let val = aliases[key];
        if (typeof val === 'string' && isGlob(key)) {
          let re = micromatch.makeRe(key, {capture: true});
          if (re.test(filename)) {
            alias = filename.replace(re, val);
            break;
          }
        }
      }
    }

    if (typeof alias === 'string') {
      return this.resolveFilename(alias, dir);
    } else if (alias === false) {
      return false;
    }

    return null;
  }
github file-icons / atom / lib / service / strategies / linguist-strategy.js View on Github external
// Only acknowledge languages with icons
				if(!languageIcon)
					return null;

				// Lazily require the micromatch dependency due to its weight.
				const Micromatch = require("micromatch");
				
				pattern = path.dirname(filePath) + "/" + (/^\//.test(pattern) ? "" : "**") + "/" + pattern;
				pattern = path.resolve(pattern);
				
				// Normalise path separators on Windows
				if("win32" === process.platform)
					pattern = pattern.replace(/\\/g, "/");
				
				pattern = Micromatch.makeRe(pattern, {
					unixify: false,
					nonegate: true,
					dot: true,
				});
				return pattern
					? [pattern, languageIcon]
					: null;
			})
			.filter(a => a);
github static-dev / spike-core / lib / config.js View on Github external
function mmToRe (mm) {
  return micromatch.makeRe(mm)
}
github skypager / skypager / src / runtimes / node / src / features / skywalker.js View on Github external
    return this.readIgnoreFiles().map(pattern => micromatch.makeRe(pattern))
  }
github mrmlnc / fast-glob / src / utils / pattern.ts View on Github external
export function makeRe(pattern: Pattern, options: MicromatchOptions): PatternRe {
	return micromatch.makeRe(pattern, options);
}
github foo-software / lighthouse-check-action / node_modules / fast-glob / out / utils / pattern.js View on Github external
function makeRe(pattern, options) {
    return micromatch.makeRe(pattern, options);
}
exports.makeRe = makeRe;

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