Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
fs-extender
Advanced tools
Extender module for node filesystem
The intention of this module is to provide many functions that don't yet exist in node fs
module, like copy
, move
, list
, find
..., and also normalize their functioning between node versions.
This module don't make any changes to node fs
module, except patching close
and closeSync
, and it can be turned off.
At its core this module works like graceful-fs
but instead of cloning the fs
module it makes an augmentation of the fs
module or any other fs
model type like. Environment Variables
This module can be used like a fs
replacement module.
Install the package
npm install --save fs-extender
import * as fs from "fs-extender";
fs.copy(dir, someOtherDir, (err) => {
if (!err) {
console.log("Directory copied with sucess.");
}
});
or
const fs = require("fs-extender");
fs.copy(dir, someOtherDir, (err) => {
if (!err) {
console.log("Directory copied with sucess.");
}
});
npm run lint
: runs the linternpm run unit
: run unit testsnpm test
: run both lint and unit testsnpm testUlimit
: run tests defining ulimit to 50
npm testMemoryLeak
: run tests to check for memoery leakagenpm testExternalFs
: run tests based on provided fs
modulenpm testExternalMockedFs
: run tests based on provided fs
module that act like a mocknpm test-all
: run all the above testsIf you find a problem with the package you can
or even make a
If you wan't to add something new, following this steps would be much apreciated:
Besides the node file system documentation for all the node fs
related functions the new methods provided can be found below.
Environment Variables - Environment variables documentation
Compare => Compare files or directories
Copy => Copy Files
Ensure => Ensure the existence of various items in file system
Find => Find items in the file system
Json => Multiple json related tools to work with files
List => List items in file system
Mkdirp => Recursive creation of directories
Move => Move items in the file system
Rm => Remove items from the file system
EmptyDir => Clean items from directory
Size => Check the size of an item in the file system
Walk => Walk through directories
For more examples just check the tests folder
First things first,
Why not use something like the graceful-fs
module?
When this module was started graceful-fs
changed the fs
module directly, that was a no go, if some of the node base modules must change it's way of functioning it must be done very carefully and in very rare occasions, just like the patch that this module implements in close
file functions, just like graceful-fs
now does, and because there's no way to don't use the graceful-fs
when it is loaded in another module in the chain (see why not using jest for tests).
Why not use something like the fs-extra
module?
Fisrt, because when this module was started the fs-extra didn't exist or was in their infancy, there where some tools like ncp
(abandoned copy module) and other's but it was a pain to use all that separated tools.
Second because fs-extra
is a fantastic module but in the background it operates (or used to) on top of graceful-fs
(see first awnser) and it doens't have all the tools and options that I needed.
Why not use Jest
for tests?
Because jest
uses fs-extra
as one of the dependencies and as we saw fs-extra
uses graceful-fs
and that makes impossible to test this module with jest
and there's no way to remove graceful-fs
from the chain, with this module you can bypass it if you wan't (see Environment Variables), even if it come from another module.
The modules that originated this module where using jest
for tests until jest
started using fs-extra
and then the number of perfectly valid tests failling was impressive, then mocha
to the rescue.
mocha
- Very good testing framework.MIT License
Copyright (c) 2011 - 2021 Joao Parreira joaofrparreira@gmail.com
FAQs
Extras suite for node fs module
The npm package fs-extender receives a total of 4 weekly downloads. As such, fs-extender popularity was classified as not popular.
We found that fs-extender demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.