Security News
RubyGems.org Adds New Maintainer Role
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.
The glob-all npm package is a utility for matching file paths using glob patterns. It extends the functionality of the standard glob package by allowing multiple patterns to be matched at once, making it easier to work with complex file matching scenarios.
Match multiple patterns
This feature allows you to match multiple glob patterns at once. In this example, it matches all JavaScript files in the 'src' and 'test' directories.
const globAll = require('glob-all');
globAll(['src/**/*.js', 'test/**/*.js'], (err, files) => {
if (err) throw err;
console.log(files);
});
Synchronous matching
This feature allows you to perform synchronous matching of multiple glob patterns. The example shows how to get all matching files synchronously.
const globAll = require('glob-all');
const files = globAll.sync(['src/**/*.js', 'test/**/*.js']);
console.log(files);
Options support
This feature allows you to pass options to the glob patterns. In this example, the 'dot' option is used to include files starting with a dot.
const globAll = require('glob-all');
globAll(['src/**/*.js', 'test/**/*.js'], { dot: true }, (err, files) => {
if (err) throw err;
console.log(files);
});
The glob package is a fundamental library for matching file paths using glob patterns. It is simpler and does not support matching multiple patterns at once like glob-all.
The fast-glob package is a high-performance alternative to glob. It supports multiple patterns and is faster, but it has a different API and may require more configuration.
The multimatch package allows matching file paths against multiple glob patterns. It is similar to glob-all but offers a more flexible API for complex matching scenarios.
Provides a similar API to glob, however instead of a single pattern, you may also use arrays of patterns.
npm install --save glob-all
Given files:
files
├── a.txt
├── b.txt
├── c.txt
└── x
├── y.txt
└── z.txt
We can:
var glob = require('glob-all');
var files = glob.sync([
'files/**', //include all files/
'!files/x/**', //then, exclude files/x/
'files/x/z.txt' //then, reinclude files/x/z.txt
]);
console.log(files);
Resulting in:
[ 'files',
'files/a.txt',
'files/b.txt',
'files/c.txt',
'files/x/z.txt' ]
Async - glob(patterns[, options], callback)
GlobAll
instance which emits:
match
error
end
Sync - glob.sync(patterns[, options])
[String]
or null
See node-glob
Since node-glob only allows one pattern, there is no such thing as an exclude pattern (like in Grunt and Gulp). However, in node-glob-all
we allow exclusion of the results of an entire pattern by prefixing the pattern with !
.
node-glob exclusions (!
inside the pattern) to exclude a portion of the path will still work as expected.
If a file occurs in more than once in the set, the one with the more precise pattern will be used and the other will be thrown away. So, if you'd like a file be in a certain position, you could do:
var glob = require('glob-all');
var files = glob.sync([
'files/x/y.txt',
'files/**'
]);
console.log(files);
Which will bring files/x/y.txt
to the top:
[ 'files/x/y.txt',
'files',
'files/a.txt',
'files/b.txt',
'files/c.txt',
'files/x',
'files/x/z.txt' ]
You can use the mark
option to mark directories with a /
, then you can:
files.filter(function(f) { return !/\/$/.test(f); });
Internally, glob-all
uses the statCache
option to prevent repeat lookups across multiple patterns.
abort()
npm install
npm start
src/index.coffee
Copyright © 2014 Jaime Pillora <dev@jpillora.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Provide multiple patterns to node-glob
The npm package glob-all receives a total of 154,982 weekly downloads. As such, glob-all popularity was classified as popular.
We found that glob-all demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
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.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.