New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fs-expand

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-expand

An extended fs glob

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33
increased by65%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Build Status Dependency Status

fs-expand

fs-expand is a standalone module to fetch all file or directory paths that match the given globbing pattern(s), which is much like grunt.file.expand

The difference from glob is that fs-expand

  • could combine the results of several glob patterns.
  • supports negative matching patterns, such as '!*.js'

expand(pattern, [options], callback);

  • pattern String|Array.<String> accepts either a single glob pattern or an array of globbing patterns. Paths matching patterns that begin with ! will be excluded from the returned array. Patterns are processed in order, so inclusion and exclusion order is significant.
  • options Object supports all glob library options
  • callback function(err, files) the callback function.
  • err Error
  • files Array.<String> filenames found matching the pattern(s)

Additioanl options

  • globOnly Boolean=false only process glob patterns, if a file does not contain globstars, fs-expand will not check the existence of the file.
<cwd>/
     |-- a.js
     |-- b.js
expand([
  '*.js',
  'abc.md'
], {
  cwd: cwd,
  globOnly: true 

}, function(err, files){
  files; 
  // -> 
  // [
  //   'a.js',
  //   'b.js',
  //   'abc.md' // actually, abc.md doesn't exist.
  // ]
});

Example

dir/
   |-- a.js
   |-- b.js
   |-- README.md
var expand = require('fs-expand');

expand(['*.js', '*.md'], {
  cwd: dir
}, function(err, files){
	console.log(files); // ['a.js', 'b.js', README.md]
});

expand.sync(pattern, [options]);

The synchronous version of expand.

Returns the filenames found.

var files = expand.sync(['*.js', '!a.js']);

console.log(files); // ['b.js']

Keywords

FAQs

Package last updated on 23 Jul 2015

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