Node.js - batchdir
Batch create directories or delete them.
Why?
I got tired of checking whether a group of directories exist before I create or make them. Even worse, when you have to check three directories:
var fs = mkdirp = ; var dirs = '/tmp/a' '/tmp/b' '/tmp/c';var i = 0; { if i < dirslength fs; else ; //<--- done } ;
Yuck.
Why not the following:
var batchdir = ; var dirs = '/tmp/a' '/tmp/b' '/tmp/c';
Much cleaner.
Installation
npm install batchdir
Methods
batchdirs()
Contsructor function.
Args:
- Array or strings.
//or
create() / mkdirs() / mkdir() / make()
Creates the directory(ies) if they don't exist. Will make full path like mkdir -p
.
Args:
- Callback function containing an
Error
object if one existed.
;
remove() / delete() / rmrf()
Deletes directory(ies) if they do exist. Will delete all of the contents like rm -rf
.
Args:
- Callback function containing an
Error
object if one existed.
;
Author
JP Richardson (@jprichardson) read my coding blog Procbits.
If you use Git with others, you should checkout Gitpilot to make collaboration with Git simple using a different GUI. We would love your feedback.
License
(MIT License)
Copyright 2012, JP Richardson jprichardson@gmail.com