function reduceDirectories() {
  return Array.prototype.slice.call(arguments)
    .map(function (candidate) {
      return path.normalize(candidate);
    })
    .filter(function (candidate) {
      return fs.existsSync(candidate) && fs.statSync(candidate).isDirectory();
    })
    .shift();
}
function reduceDirectories() {
  return Array.prototype.slice.call(arguments)
    .map(function (candidate) {
      return path.normalize(candidate);
    })
    .filter(function (candidate) {
      return fs.existsSync(candidate) && fs.statSync(candidate).isDirectory();
    })
    .shift();
}
function reduceDirectories ( ) { return Array . prototype . slice . call ( arguments ) . map ( function ( candidate ) { return path . normalize ( candidate ) ; } ) . filter ( function ( candidate ) { return fs . existsSync ( candidate ) && fs . statSync ( candidate ) . isDirectory ( ) ; } ) . shift ( ) ; }
Pick the first existing directory from any of the given arguments.
@param {...string} candidates Any number of possible directories
@returns {string} The first valid directory or else undefined
Pick the first existing directory from any of the given arguments .