Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 804 Bytes

.verb.md

File metadata and controls

45 lines (35 loc) · 804 Bytes

Usage

var deleteEmpty = require('{%= name %}');

API

Given the following directory structure, the highlighted directories would be deleted.

foo/
└─┬ a/
-  ├── aa/
  ├── bb/
  │ └─┬ bbb/
  │   ├── one.txt
  │   └── two.txt
-  ├── cc/
-  ├ b/
-  └ c/

async

deleteEmpty('foo/', function(err, deleted) {
  console.log(deleted);
  //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
});

sync

deleteEmpty.sync('foo/');

As with the async method, an array of deleted directories is returned, in case you want to log them out or provide some kind of feedback to the user.

var deleted = deleteEmpty.sync('foo/');
console.log(deleted);
//=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']