davglass/yuidocjs — Issue #30: copyDirectory fails if there are empty directories
Author: nfrias
Created: 2012-02-21 20:48:34+00:00
State: open

If there are empty directories, the afterRaadDir never calls the callback. The fix is to call it immediately if there are no files to copy:

```
function afterReadDir(err, files) {
if (err) { return callback(err); }

var pending = files.length,
filename;

if (!pending) { return callback(); }

while ((filename = files.shift())) {
copyPath(fsPath.join(source, filename), fsPath.join(dest, filename), overwrite, function (err) {
if (err) { return callback(err); }

pending -= 1;

if (!pending) {
callback();
}
});
}
}
```