Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
fstream-ignore
Advanced tools
The fstream-ignore npm package is a specialized file stream filter that allows you to include or exclude files based on .gitignore-style rules. It is particularly useful for creating tarballs, zips, or other file archives where you need to exclude certain files or directories.
Filtering files based on .gitignore rules
This feature allows you to filter files in a directory based on rules specified in .gitignore files. The code sample demonstrates how to create an Ignore stream that reads from a directory and applies the ignore rules.
const Ignore = require('fstream-ignore');
const ignore = new Ignore({ path: 'path/to/dir', ignoreFiles: ['.gitignore'] });
ignore.on('child', function (c) {
console.error(c.path);
});
ignore.on('end', function () {
console.error('done');
});
Custom ignore rules
This feature allows you to specify custom ignore rules directly in the code, without relying on an external .gitignore file. The code sample shows how to create an Ignore stream with custom rules to exclude .log files and the node_modules directory.
const Ignore = require('fstream-ignore');
const ignore = new Ignore({ path: 'path/to/dir', ignoreRules: ['*.log', 'node_modules/'] });
ignore.on('child', function (c) {
console.error(c.path);
});
ignore.on('end', function () {
console.error('done');
});
The ignore package is a standalone utility for handling .gitignore-style rules. It provides a more flexible and powerful API for managing ignore rules, but it does not integrate directly with file streams like fstream-ignore.
The minimatch package is a glob matching library that can be used to match file paths against patterns. While it does not specifically handle .gitignore rules, it can be used to implement similar functionality with custom logic.
The glob package is a file matching library that allows you to find files based on glob patterns. It can be used in conjunction with ignore rules to filter files, but it does not natively support .gitignore-style rules.
A fstream DirReader that filters out files that match globs in .ignore
files throughout the tree, like how git ignores files based on a
.gitignore
file.
Here's an example:
var Ignore = require("fstream-ignore")
Ignore({ path: __dirname
, ignoreFiles: [".ignore", ".gitignore"]
})
.on("child", function (c) {
console.error(c.path.substr(c.root.path.length + 1))
})
.pipe(tar.Pack())
.pipe(fs.createWriteStream("foo.tar"))
This will tar up the files in __dirname into foo.tar
, ignoring
anything matched by the globs in any .iginore or .gitignore file.
FAQs
A thing for ignoring files based on globs
The npm package fstream-ignore receives a total of 223,160 weekly downloads. As such, fstream-ignore popularity was classified as popular.
We found that fstream-ignore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.