Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Expands file patterns, returning the matched and unmatched files and directories.
The file-set npm package allows you to easily include and exclude files using glob patterns. It is useful for tasks such as file manipulation, filtering, and organizing files based on specific patterns.
Include Files
This feature allows you to include files that match a specific glob pattern. In this example, all JavaScript files in the 'src' directory and its subdirectories are included.
const fileSet = require('file-set');
fileSet('src/**/*.js', function(err, files) {
if (err) throw err;
console.log(files);
});
Exclude Files
This feature allows you to exclude files that match a specific glob pattern. In this example, all JavaScript files in the 'src' directory and its subdirectories are included, except for files named 'test.js'.
const fileSet = require('file-set');
fileSet(['src/**/*.js', '!src/**/test.js'], function(err, files) {
if (err) throw err;
console.log(files);
});
Multiple Patterns
This feature allows you to include files from multiple patterns. In this example, all JavaScript files in both the 'src' and 'lib' directories and their subdirectories are included.
const fileSet = require('file-set');
fileSet(['src/**/*.js', 'lib/**/*.js'], function(err, files) {
if (err) throw err;
console.log(files);
});
The 'glob' package is a popular library for matching files using glob patterns. It is more flexible and powerful than file-set, but requires more configuration and does not support exclusion patterns as easily.
The 'fast-glob' package is a high-performance alternative to 'glob'. It supports advanced features like negative patterns for exclusion and is faster, making it suitable for large projects with many files.
The 'multimatch' package allows you to match files against multiple glob patterns, including support for exclusion patterns. It is similar to file-set but offers more advanced pattern matching capabilities.
#file-set
Exports a contructor taking a list of file patterns as input, returning a file-set
instance containing the expanded patterns split into separate lists of files
, dirs
and notExisting
.
Example
var fileSet = require("file-set");
##Install
$ npm install file-set --save
##Usage
> var fileSet = require("file-set");
> var ls = fileSet([ "*", "not/existing/*" ])
{ list:
[ { path: 'README.md', type: 1 },
{ path: 'jsdoc2md', type: 2 },
{ path: 'lib', type: 2 },
{ path: 'node_modules', type: 2 },
{ path: 'package.json', type: 1 },
{ path: 'test', type: 2 },
{ path: 'not/existing/*', type: 0 } ],
files: [ 'README.md', 'package.json' ],
dirs:
[ 'jsdoc2md',
'lib',
'node_modules',
'test' ],
notExisting: [ 'not/existing/*' ] }
#API ##class: FileSet ⏏ Expands file patterns, returning the matched and unmatched files and directories
Members
###new FileSet(patternList) Params
string
| Array.<string>
- A pattern, or array of patterns to expand###fileSet.list The full list of unique paths found, and not found.
Type: Array.<string>
###fileSet.files
The existing files found
Type: Array.<string>
###fileSet.dirs
The existing directories found
Type: Array.<string>
###fileSet.notExisting
Paths which were not found
Type: Array.<string>
###enum: FileSet.eFileType
Enum for the type
value of each record in fileSet.list
Type: number
Properties: NOEXIST
, FILE
, DIR
Read only: true
###fileSet.add(files)
add file patterns to the set
Params
string
| Array.<string>
- A pattern, or array of patterns to expanddocumented by jsdoc-to-markdown
FAQs
Cross-platform glob expansions simplified. Input: file paths and glob expressions. Output: resolved file paths organised by type (file, directory and not-found).
The npm package file-set receives a total of 185,625 weekly downloads. As such, file-set popularity was classified as popular.
We found that file-set demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.