How to use matched - 10 common examples

To help you get started, we’ve selected a few matched 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 jonschlinkert / resolve-dep / index.js View on Github external
resolveDep.local = function(patterns, options) {
  options = options || {};
  options.cwd = options.srcBase = cwd(options.cwd || process.cwd());
  patterns = arrayify(arrayify(patterns));
  if (!patterns.length) {
    return [];
  }
  // find local matches
  return glob.sync(patterns, options).map(function(filepath) {
    return lookup(filepath, options.cwd);
  });
};
github jonschlinkert / delete / index.js View on Github external
del.promise = function delPromise(patterns, options) {
  var opts = extend({cwd: process.cwd()}, options);
  var deleted = [];

  if (patterns === '' && isCurrentDir(opts.cwd)) {
    return Promise.resolve(deleted);
  }

  return glob.promise(patterns, opts)
    .then(function(files) {
      // sync is actually faster than async most of the time
      files.forEach(function(fp) {
        del.sync(fp, opts);
        deleted.push(fp);
      });
      return deleted;
    });
};
github jonschlinkert / template / test / loaders.js View on Github external
return Promise.method(function (patterns, opts) {
          return glob.sync(patterns, opts);
        });
      });
github jonschlinkert / template / test / loaders.js View on Github external
app.create('file', opts, function (views, opts) {
          return glob.bind(glob);
        });
github jonschlinkert / merge-configs / index.js View on Github external
resolve(type) {
    const config = this.type(type);
    const files = glob.sync(config.patterns, config.options);
    const cwd = config.options.cwd;
    const res = [];

    for (let filename of files) {
      const filepath = path.resolve(cwd, filename);
      const file = new File({path: filepath, cwd: cwd});
      if (typeof config.filter === 'function') {
        if (config.filter(file) === false) {
          continue;
        }
      }
      res.push(file);
    }
    return res;
  }
github jonschlinkert / gray-matter / benchmark / support.js View on Github external
function files(cwd, patterns, opts) {
  return glob.sync(path.join(cwd, patterns), opts);
}
github ContentMine / getpapers / lib / eupmc.js View on Github external
EuPmc.prototype.summariseMinedTerms = function () {
  log.info('Writing mined term summary CSV files to minedterms_summary/')
  mkdirp.sync('minedterms_summary')
  var termstore = {}
  glob.sync(['*/textMinedTerms.json']).forEach(function (termsFile) {
    var json = fs.readFileSync(termsFile, 'utf8')
    var terms = JSON.parse(json)
    terms.semanticTypeList.semanticType.forEach(function (termset) {
      if (!termstore[termset.name]) {
        termstore[termset.name] = []
      }
      var rows = termset.tmSummary.map(function (term) {
        return [
          terms.request.id,
          '"' + term.term + '"',
          term.count,
          term.dbname,
          term.dbIdList.dbId.join(';')
        ]
      })
      termstore[termset.name] = termstore[termset.name].concat(rows)
github jonschlinkert / get-value / benchmark / check.js View on Github external
function files(base, pattern) {
  return glob.sync(toGlob(base, pattern));
}
github todogroup / repolinter / lib / file_system.js View on Github external
glob (globs, options) {
    return glob.sync(globs, options)
      .filter(relativePath => this.shouldInclude(relativePath))
  }
github jonschlinkert / load-templates / index.js View on Github external
globViews(patterns, options) {
    patterns = utils.arrayify(patterns);
    const opts = Object.assign({ cwd: process.cwd() }, this.options, options);
    delete opts.nonull;

    for (let i = 0; i < patterns.length; i++) {
      const pattern = patterns[i];
      const is = isGlob(pattern);

      let files = is ? glob.sync(pattern, opts) : [];
      if (files.length === 0) {
        files = !is ? [pattern] : [];
      } else {
        files = files.map(f => path.resolve(opts.cwd, f));
      }

      if (files.length) {
        const parent = path.resolve(is ? globParent(pattern) : '.');
        const base = path.resolve(opts.cwd, parent);
        this.addViews(files, Object.assign({}, options, { base: base }));
      }
    }
    return this.cache;
  }

matched

Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules.

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular matched functions