GithubHelp home page GithubHelp logo

Add an empty option about make-dir HOT 6 CLOSED

sindresorhus avatar sindresorhus commented on May 24, 2024
Add an empty option

from make-dir.

Comments (6)

papb avatar papb commented on May 24, 2024 1

Side note: this can be done with dir in fs-jetpack

from make-dir.

RyanZim avatar RyanZim commented on May 24, 2024

Can also be done with fs-extra emptyDir https://github.com/jprichardson/node-fs-extra/blob/master/docs/emptyDir.md

from make-dir.

zkochan avatar zkochan commented on May 24, 2024

but it starts with readdir

https://github.com/jprichardson/node-fs-extra/blob/a2738d390694ae8dc32a8c27e76db08c9963e570/lib/empty/index.js#L11

In my case, it is an edge case that the target directory exists. So I'd prefer if it starts with the mkdir command and only removes the directory if an EEXIST exception is thrown.

from make-dir.

RyanZim avatar RyanZim commented on May 24, 2024

Honestly, if you need to be that hyper-optimized, you're probably best off embedding the function in your own code; because there are many other use-cases where it would be more efficient to do the exact opposite. A library can't cover all cases with highest efficiency.

from make-dir.

zkochan avatar zkochan commented on May 24, 2024

I might do that. But make-dir almost does what I need. It runs mkdir without checking the existence of the directory first. So adding an empty option would not be a breaking change.

from make-dir.

zkochan avatar zkochan commented on May 24, 2024

I guess I will create a new package for this. This one is not that useful anymore, as NodeJS supports recursive mkdir natively

from make-dir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.