npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fs-extender

v1.0.3

Published

Extras suite for node fs module

Downloads

103

Readme

FS-EXTENDER

Extender module for node filesystem


Codacy Badge Test Status


Description

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.

Usage

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.");
    }
});

Runing tests

  • npm run lint: runs the linter
  • npm run unit: run unit tests
  • npm test: run both lint and unit tests
  • npm testUlimit: run tests defining ulimit to 50
  • npm testMemoryLeak: run tests to check for memoery leakage
  • npm testExternalFs: run tests based on provided fs module
  • npm testExternalMockedFs: run tests based on provided fs module that act like a mock
  • npm test-all: run all the above tests

Contribute

If you find a problem with the package you can

  • Submit a Bug
    • If you provide a test case it will make the issue resolution faster

or even make a

Add something new

If you wan't to add something new, following this steps would be much apreciated:

  • Develop the new helper, with clean and readable code
  • Develop tests for the new helper
  • Include in the comments a description of what the helper does, the input arguments and what it returns

Documentation

Besides the node file system documentation for all the node fs related functions the new methods provided can be found below.

Examples

For more examples just check the tests folder

Why this module

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.

Credits

  • ncp - One of the modules that originated all this module (forget about the name of some others)
  • graceful-fs - A very good module for patching the fs module but with some flaws mainly the lack of an option to bypass the module
  • fs-extra - A very good module but that don't have all the tools needed for the job (or options for the tools)
  • mocha - Very good testing framework.

License

MIT License

Copyright (c) 2011 - 2021 Joao Parreira [email protected]