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

makedir

v0.0.11

Published

recursively make directories that you need in node.js

Downloads

26

Readme

makedir

Recursively and asyncronously make directories in node.js.

There is another great library called mkdirp that a lot more people use.

I wrote this one independently of that one, and after comparing the code, they do about the same thing.

If you want a widely used, well supported mkdirp, use node-mkdirp. On the other hand, this one works too.

The primary use case I wrote this library for was to make RESTful file system caches of rather expensive-to-create database queries on a web server. Other solutions couldn't handle multiple simultaneous creates that you get from asyncronous operation. For example, if a request asks for foo/bar/baz/batch.txt, and another, simultaneous request asks for foo/bar/bit/bang.txt, then both requests will try to create directories foo/bar. Unless they are careful, one of the processes will erroneously try to create a directory that already exists, and will crash. At the time I wrote this way long time ago, the other libraries I tested would crash.

Installation

To install, do

npm install makedir

Usage

To use, just pass the directory that you want to make. It will climb up the directory tree until it finds something that exist, and then will recursively create all of the directories that are needed. Pass it a callback to do something with that directory once it is created. For example

var makedir = require('makedir');
var p = '/home/james/some/crazy/long/path'
function doSomethingToPath(path){
      return function(err){
          if(err) throw new Error (err);
          console.log('made '+path);
      };
};
makedir.makedir(p,doSomethingToPath(p));

Testing

To run the tests, clone the repository, then:

 npm install
 npm test

or

 mocha test

I just revised my tests to use mocha, and now I actually clean up the mess of temp directories.

If you want to prove to yourself that the tests are creating directories, go into the tests and delete or comment out the "after" bit that clean up the temp directories.

Copyright

Copyright (c) 2012-2014 James E. Marca, using the MIT licence.