Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Super fast globbing library.
Install with npm:
npm i matched --save-dev
├── node_modules/...
├── index.js
├── README.md
└── test/test.js
matched(patterns, options)
See supported globby options.
Required
Type: string|array
See minimatch for options and supported patterns.
Type: object
Matched excludes certain directories to speed up search.
Type: array
Default: ['.git', 'node_modules', 'temp', 'tmp']
Pass an array of additional directories to exclude:
matched(['**/*.js'], {omit: ['vendor']});
See node-glob for all supported options.
In the command line, run:
mocha
Just a quick overview.
*
matches any number of characters, but not /
?
matches a single character, but not /
**
matches any number of characters, including /
, as long as it's the only thing in a path part{}
allows for a comma-separated list of "or" expressions!
at the beginning of a pattern will negate the matchVarious patterns and expected matches.
See multimatch if you need to match against a list instead of the filesystem.
Problem
Let's say you want to return all of the .js
files in a project, excluding node_modules
and a few other similar directories. Normally you would need to do something like this:
glob(['**/*.js', '!**/node_modules/**']);
The problem with this approach is that typically even the excluded file paths are fully expanded before the result set is returned. e.g. all of the files in node_modules
would be scanned first.
Solution
Matched allows you to exlude directories before they reach globby. In a nutshell, matched uses fs.readdirSync
to build up a list of directories relative to the cwd
, then for each (non-excluded) directory matched passes the glob pattern to globby. The following is all that's needed to return all of the .js
files in a project.
var matched = require('matched');
matched('**/*.js');
//=> ['index.js', 'test/test.js']
Try it, you'll be surprised how fast it is comparatively. However, I'm not sure how well this approach will scale with complicated patterns. See the tests for the use cases that are covered so far. Feel free to create pull requests or issues if you have suggestions for improvement.
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on June 26, 2014.
FAQs
Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules.
The npm package matched receives a total of 100,475 weekly downloads. As such, matched popularity was classified as popular.
We found that matched demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.