var deleteEmpty = require('{%= name %}');
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/']