include.js
function findProjectRoot(currentPath) {
  var result = undefined;

  try {
    var packageStats = lstatSync(path.join(currentPath, 'package.json'));

    if (packageStats.isFile()) {
      result = currentPath;
    }
  } catch (error) {
    if (currentPath !== path.resolve('/')) {
      result = findProjectRoot(path.join(currentPath, '..'));
    }
  }

  return result;
}
function findProjectRoot(currentPath) {
  var result = undefined;

  try {
    var packageStats = lstatSync(path.join(currentPath, 'package.json'));

    if (packageStats.isFile()) {
      result = currentPath;
    }
  } catch (error) {
    if (currentPath !== path.resolve('/')) {
      result = findProjectRoot(path.join(currentPath, '..'));
    }
  }

  return result;
}
function findProjectRoot ( currentPath ) { var result = undefined ; try { var packageStats = lstatSync ( path . join ( currentPath , 'package.json' ) ) ; if ( packageStats . isFile ( ) ) { result = currentPath ; } } catch ( error ) { if ( currentPath !== path . resolve ( '/' ) ) { result = findProjectRoot ( path . join ( currentPath , '..' ) ) ; } } return result ; }
Attempts to find the project root by finding the nearest package.json file.
@private
@param {String} currentPath - Path of the file doing the including.
@return {String?}
Attempts to find the project root by finding the nearest package . json file .