
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
The dir-glob npm package is designed to convert directory paths into glob patterns, which can then be used with other tools that work with globs, such as file system search utilities. This can be particularly useful for including or excluding entire directories when working with file patterns.
Convert directories to glob patterns
This feature allows you to convert an array of directory paths into glob patterns that match all files within those directories. The example demonstrates converting two directory paths into their corresponding glob patterns.
const dirGlob = require('dir-glob');
(async () => {
const paths = await dirGlob(['assets', 'uploads']);
console.log(paths);
//=> ['assets/**', 'uploads/**']
})();
Include file extensions in glob patterns
This feature extends the basic directory-to-glob conversion by allowing you to specify file extensions. This results in glob patterns that match only files with the specified extensions within the given directories. The example shows how to generate glob patterns for jpg and png files only.
const dirGlob = require('dir-glob');
(async () => {
const paths = await dirGlob(['assets', 'uploads'], {extensions: ['jpg', 'png']});
console.log(paths);
//=> ['assets/**/*.jpg', 'assets/**/*.png', 'uploads/**/*.jpg', 'uploads/**/*.png']
})();
The 'glob' package provides pattern matching functionality for file paths. While 'glob' itself focuses on matching patterns against existing file structures, 'dir-glob' specifically converts directory paths into glob patterns. 'glob' can be used in conjunction with 'dir-glob' to first generate glob patterns for directories and then match those patterns against files.
Similar to 'glob', 'fast-glob' is an optimized version that provides a faster and more efficient way to match glob patterns against file systems. It offers a similar functionality to 'dir-glob' in terms of working with glob patterns, but it does not specifically focus on converting directories to globs. Instead, it's more about performing the matching operation itself, potentially using patterns generated by 'dir-glob'.
Convert directories to glob compatible strings
$ npm install dir-glob
const dirGlob = require('dir-glob');
(async () => {
console.log(await dirGlob(['index.js', 'test.js', 'fixtures']));
//=> ['index.js', 'test.js', 'fixtures/**']
console.log(await dirGlob(['index.js', 'inner_folder'], {cwd: 'fixtures'}));
//=> ['index.js', 'inner_folder/**']
console.log(await dirGlob(['lib/**', 'fixtures'], {
files: ['test', 'unicorn']
extensions: ['js']
}));
//=> ['lib/**', 'fixtures/**/test.js', 'fixtures/**/unicorn.js']
console.log(await dirGlob(['lib/**', 'fixtures'], {
files: ['test', 'unicorn', '*.jsx'],
extensions: ['js', 'png']
}));
//=> ['lib/**', 'fixtures/**/test.{js,png}', 'fixtures/**/unicorn.{js,png}', 'fixtures/**/*.jsx']
})();
Returns a Promise<string[]>
with globs.
Returns a string[]
with globs.
Type: string | string[]
Paths.
Type: object
Type: string[]
Append extensions to the end of your globs.
Type: string[]
Only glob for certain files.
Type: string[]
Test in specific directory.
FAQs
Convert directories to glob compatible strings
The npm package dir-glob receives a total of 37,611,533 weekly downloads. As such, dir-glob popularity was classified as popular.
We found that dir-glob demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.