How to use the minimatch.Minimatch function in minimatch

To help you get started, we’ve selected a few minimatch 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 electron-userland / electron-builder / packages / app-builder-lib / src / fileMatcher.ts View on Github external
computeParsedPatterns(result: Array, fromDir?: string): void {
    const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from)

    if (this.patterns.length === 0 && relativeFrom != null) {
      // file mappings, from here is a file
      result.push(new Minimatch(relativeFrom, minimatchOptions))
      return
    }

    for (let pattern of this.patterns) {
      if (relativeFrom != null) {
        pattern = path.join(relativeFrom, pattern)
      }

      const parsedPattern = new Minimatch(pattern, minimatchOptions)
      result.push(parsedPattern)

      // do not add if contains dot (possibly file if has extension)
      if (!pattern.includes(".") && !hasMagic(parsedPattern)) {
        // https://github.com/electron-userland/electron-builder/issues/545
        // add **/*
        result.push(new Minimatch(`${pattern}/**/*`, minimatchOptions))
github angular / dgeni-packages / base / processors / read-files.js View on Github external
function getSourceFiles(sourceInfo) {

  var excludeMatcher = sourceInfo.exclude && new Minimatch(sourceInfo.exclude);

  var filesPromise = Q.nfcall(glob, sourceInfo.include);

  return filesPromise.then(function(files) {

    // Filter the files on whether they match the `exclude` property and whether they are files
    var filteredFilePromises = files.map(function(file) {

      if ( excludeMatcher && excludeMatcher.match(file) ) {
        // Return a promise for `null` if the path is excluded
        // Doing this first - it is synchronous - saves us even making the isFile call if not needed
        return Q(null);
      } else {
        // Return a promise for the file if path is a file, otherwise return a promise for `null`
        return qfs.isFile(file).then(function(isFile) { return isFile ? file : null; });
      }
github electron-userland / electron-builder / packages / app-builder-lib / src / fileMatcher.ts View on Github external
computeParsedPatterns(result: Array, fromDir?: string): void {
    const relativeFrom = fromDir == null ? null : path.relative(fromDir, this.from)

    if (this.patterns.length === 0 && relativeFrom != null) {
      // file mappings, from here is a file
      result.push(new Minimatch(relativeFrom, minimatchOptions))
      return
    }

    for (let pattern of this.patterns) {
      if (relativeFrom != null) {
        pattern = path.join(relativeFrom, pattern)
      }

      const parsedPattern = new Minimatch(pattern, minimatchOptions)
      result.push(parsedPattern)

      // do not add if contains dot (possibly file if has extension)
      if (!pattern.includes(".") && !hasMagic(parsedPattern)) {
        // https://github.com/electron-userland/electron-builder/issues/545
        // add **/*
        result.push(new Minimatch(`${pattern}/**/*`, minimatchOptions))
      }
    }
  }
github brunosimon / keppler / lib / watcher.js View on Github external
setExcludeRegex()
    {
        // Exclude files regex
        const regexs = []
        const Minimatch = require('minimatch').Minimatch

        for(const _excludeKey in this.config.exclude)
        {
            const _exclude = this.config.exclude[_excludeKey]
            const minimatch = new Minimatch(_exclude, { dot: true })

            let regex = '' + minimatch.makeRe()

            regex = regex.replace('/^', '')
            regex = regex.replace('$/', '')

            regexs.push(regex)
        }

        this.excludeRegex = new RegExp(regexs.join('|'))
    }
github facebookarchive / atom-ide-ui / modules / atom-ide-debugger-python / VendorLib / vs-py-debugger / out / client / linters / lintingEngine.js View on Github external
            const ignoreMinmatches = settings.linting.ignorePatterns.map(pattern => new minimatch_1.Minimatch(pattern));
            if (ignoreMinmatches.some(matcher => matcher.match(document.fileName) || matcher.match(relativeFileName))) {
github fimbullinter / wotan / packages / wotan / src / configuration.ts View on Github external
function matchesGlobs(file: string, patterns: string[]): boolean {
    for (let i = patterns.length - 1; i >= 0; --i) {
        const glob = isNegated(patterns[i]);
        const local = glob.pattern.startsWith('./');
        if (local)
            glob.pattern = glob.pattern.substr(2);
        if (new Minimatch(glob.pattern, {matchBase: !local}).match(file))
            return !glob.negated;
    }
    return false;
}
github jallajs / jalla / index.js View on Github external
function normalizeSkip (val) {
  if (val instanceof RegExp) {
    return val.test.bind(val)
  } else if (typeof val === 'function') {
    return val
  } else if (typeof val === 'string') {
    var minimatch = new Minimatch(val)
    return function (str) {
      return str.includes(val) || minimatch.match(str)
    }
  } else {
    throw new Error('Skip should be either a RegExp, function or string')
  }
}
github doZennn / steam-rom-manager / src / lib / parsers / glob-regex.parser.ts View on Github external
let getRegexString = (segment: string) => {
            let mm = new minimatch.Minimatch(segment, { dot: true });
            if (mm.empty)
                return '^\\s*?$';
            else{
                return mm.makeRe().source;
            }
        }
github nativescript-rtl / ui / node_modules / tslint / lib / configuration.js View on Github external
    return configFile.linterOptions.exclude.some(function (pattern) { return new minimatch_1.Minimatch(pattern).match(fullPath); });
}
github angular / angular-cli / packages / angular_devkit / build_angular / src / tslint / index.ts View on Github external
      .map(pattern => new Minimatch(path.normalize(pattern), { dot: true }));