Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dir-glob

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-glob

Convert directories to glob compatible strings

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30M
decreased by-19%
Maintainers
2
Weekly downloads
 
Created

What is dir-glob?

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.

What are dir-glob's main functionalities?

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']
})();

Other packages similar to dir-glob

Keywords

FAQs

Package last updated on 29 Jun 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc