code: function findProjectRoot(startPath) {
      log.trace("findProjectRoot startPath = %s", startPath);
      if(isDiskRoot()) {
        if(hasPackageJson()) {
          return startPath;
        } else {
          throw new Error("Cannot find project root");
        }
      } else if(hasPackageJson()) {
        return startPath;
      } else {
        return findProjectRoot(PATH.resolve(startPath+PATH.sep+".."));
      }
  
      function hasPackageJson() {
        return fs.existsSync(startPath+PATH.sep+"package.json");
      }
  
      function isDiskRoot() {
        return startPath.match(/^([A-Z]:\\\\|\/)$/);
      }
    }
docs: Going up the folder tree returns the first
  folder with package.json present.
  
  @param startPath
  @returns {*}