code: function getPackageRoot (dir) {
      let lastDir = null;
      while (lastDir !== dir && !fs.existsSync(path.resolve(dir, "./package.json"))) {
          lastDir = dir;
          dir = path.dirname(dir);
      }
      return (lastDir === dir ? null : dir);
  }
docs: Navigates upwards to the closest dir that contains a 'package.json'.
  @param dir {string} Directory to start from.