confdir.js
function findDirRec(dir, callback) {
      var result = path.resolve(dir, dirmod);
      fs.stat(result, function stat(err, stat) {
        if (err || !stat.isDirectory()) {
          if (lastResult == result) {
            callback(new Error('No configuration directory found.'));
            return;
          }
          lastResult = result;
          findDirRec(path.resolve(dir, '..'), callback);
        } else {
          callback(null, result);
        }
      });
    }
function findDirRec(dir, callback) {
      var result = path.resolve(dir, dirmod);
      fs.stat(result, function stat(err, stat) {
        if (err || !stat.isDirectory()) {
          if (lastResult == result) {
            callback(new Error('No configuration directory found.'));
            return;
          }
          lastResult = result;
          findDirRec(path.resolve(dir, '..'), callback);
        } else {
          callback(null, result);
        }
      });
    }
function findDirRec ( dir , callback ) { var result = path . resolve ( dir , dirmod ) ; fs . stat ( result , function stat ( err , stat ) { if ( err || ! stat . isDirectory ( ) ) { if ( lastResult == result ) { callback ( new Error ( 'No configuration directory found.' ) ) ; return ; } lastResult = result ; findDirRec ( path . resolve ( dir , '..' ) , callback ) ; } else { callback ( null , result ) ; } } ) ; }
find dirname by recursively walking up the path hierarchy
find dirname by recursively walking up the path hierarchy