jonschlinkert / delete-empty

Recursively delete all empty folders in a directory and child directories.
MIT License
43 stars 10 forks source link

Callback doesn't default to an empty function #6

Closed Dan503 closed 8 years ago

Dan503 commented 8 years ago

This doesn't work

deleteEmpty('folder/');

But this does:

deleteEmpty('folder/',function(){});
jonschlinkert commented 8 years ago

right, that's an anti-pattern for async usage at this level. Implementors can do what you did in your example, or you could use deleteEmpty.sync.

Dan503 commented 8 years ago

If all you want to do is apply a quick asynchronous folder clean then this syntax should be allowed

deleteEmpty('folder/');

The callback parameter just needs this applied to it

callback = typeof callback === 'undefined' ? callback  : function(){};

I don't see why you want to force your users to use this syntax:

deleteEmpty('folder/',function(){});

It's unintuitive having to write that.