ryanmcgrath / wrench-js

Recursive file operations in Node.js
MIT License
435 stars 71 forks source link

copyDirRecursive callback doesn't always receive error as the first parameter #47

Closed ViciousPotato closed 11 years ago

ViciousPotato commented 11 years ago

Sometimes it receives nothing. It causes pain to use with other libraries that expect at least a null error.

Consider being used in async.waterfall, we have to

  async.waterfall([
    function(next) {
      wrench.copyDirRecursive(
        sourceDir, 
        destDir, 
        function(error) {
          // The problem with wrench is that when succeeds it will call callback
          // with nothing.
          if (error) return next(error);
          next(null);
        });
    },
    function(next) {
       ...
    }], callback);
};

instead of

  async.waterfall([
    function(next) {
      wrench.copyDirRecursive(
        sourceDir, 
        destDir, 
        next)
    },
    function(next) {
       ...
    }], callback);
};
ryanmcgrath commented 11 years ago

Your pull request done fixed this here issue. Thanks!