How to use the minimatch.filter 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 accordproject / concerto / packages / composer-common / lib / businessnetworkdefinition.js View on Github external
static _processDependencies(jsonObject,path,options,modelFiles,modelFileNames){
        const method='_processDependencies';
        LOG.debug(method, 'All dependencies', Object.keys(jsonObject.dependencies).toString());
        const dependencies = Object.keys(jsonObject.dependencies).filter(minimatch.filter(options.dependencyGlob, { dot: true }));
        LOG.debug(method, 'Matched dependencies', dependencies);

        for( let dep of dependencies) {
        // find all the *.cto files under the npm install dependency path
            let dependencyPath = fsPath.resolve(path, 'node_modules', dep);
            LOG.debug(method, 'Checking dependency path', dependencyPath);
            if (!fs.existsSync(dependencyPath)) {
            // need to check to see if this is in a peer directory as well
            //
                LOG.debug(method,'trying different path '+path.replace(jsonObject.name,''));
                dependencyPath = fsPath.resolve(path.replace(jsonObject.name,''),dep);
                if(!fs.existsSync(dependencyPath)){
                    throw new Error('npm dependency path ' + dependencyPath + ' does not exist. Did you run npm install?');
                }
            }
github manheim / metalsmith-jquery / lib / index.js View on Github external
var globFilter = function() { return true; };
	var options = false;

	if (param2 &&  typeof param2 === "object") {
	   // when used in the following manner module(some transform function or transform script filename, some cheerio options) 
		options = param2
	}

	if (param3 && typeof param3 === "object") {
	    // when used in the following manner module('filter',some transform function or transform script filename, some cheerio options) 
		options = param3
	}

    if (param2 && typeof param2 !== "object") {
	  // when used in the following manner module('filter',some transform function or transform script filename) 
      globFilter = minimatch.filter(param1);

      // shift parameters
      param1 = param2;
    }
	
    if (typeof param1 === "string") {
        var filename = path.resolve(process.cwd(), param1);
        debug("Loading file: " + filename);
        transform = require(filename);
    } else if (typeof param1 !== "function") {
        debug("No transform function found");
    } else {
        transform = param1;
    }
github preactjs / preact-www / webpack.config.babel.js View on Github external
import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
import CrittersPlugin from 'critters-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import CleanPlugin from 'clean-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import autoprefixer from 'autoprefixer';
import rreaddir from 'recursive-readdir-sync';
import minimatch from 'minimatch';
// import ssr from './src/ssr';
import config from './src/config.json';

// global.fetch = require('isomorphic-fetch');
// import 'isomorphic-fetch';
// import './src/lib/polyfills';

const CONTENT = rreaddir('content').filter(minimatch.filter('**/*.md')).filter(minimatch.filter('!content/lang/**')).map( s => '/'+s );

const ENV = process.env.NODE_ENV || 'development';

const CSS_MAPS = ENV!=='production';

const VENDORS = /\bbabel\-standalone\b/;

const babelConfig = JSON.parse(fs.readFileSync('./.babelrc', 'utf-8'));
babelConfig.presets[0][1].modules = false;

module.exports = {
	context: path.resolve(__dirname, 'src'),
	// entry: {
	// 	polyfills: path.resolve(__dirname, 'src/lib/polyfills.js'),
	// 	main: path.resolve(__dirname, 'src/index.js')
	// },
github ionic-team / stencil / src / compiler / output-targets / output-copy.ts View on Github external
return tasks.filter(copy => {
      let copySrc = copy.src;
      if (isGlob(copySrc)) {
        // test the glob
        copySrc = config.sys.path.join(config.srcDir, copySrc);
        if (changedFiles.some(minimatch.filter(copySrc))) {
          return true;
        }
      } else {
        copySrc = normalizePath(getSrcAbsPath(config, copySrc + '/'));
        if (changedFiles.some(f => f.startsWith(copySrc))) {
          return true;
        }
      }
      return false;
    });
  }
github postcss / postcss-url / src / lib / match-options.js View on Github external
const matchesFilter = (asset, pattern) => {
    const relativeToRoot = path.relative(process.cwd(), asset.absolutePath);

    if (typeof pattern === 'string') {
        pattern = minimatch.filter(pattern);

        return pattern(relativeToRoot);
    }

    if (pattern instanceof RegExp) {
        return pattern.test(relativeToRoot);
    }

    if (pattern instanceof Function) {
        return pattern(asset);
    }

    return true;
};
github strongloop / loopback-datasource-juggler / lib / connectors / kv-memory.js View on Github external
function createMatcher(pattern) {
  if (!pattern) return function matchAll() { return true; };

  return minimatch.filter(pattern, {
    nobrace: true,
    noglobstar: true,
    dot: true,
    noext: true,
    nocomment: true,
  });
}
github microsoft / azure-pipelines-tasks / Tests / lib / vso-task-lib / lib / vsotask.js View on Github external
function filter(pattern, options) {
    return minimatch.filter(pattern, options);
}
exports.filter = filter;
github streetsidesoftware / cspell / packages / cspell-lib / src / exclusionHelper.ts View on Github external
    const fns = globs.map(glob => minimatch.filter(glob, { matchBase: true }));