async function findPackageFor(filepath) {
  let directory = filepath;

  while (directory !== '/') {
    const directoryToSearch = path.dirname(directory);
    const files = await fs.readdir(directoryToSearch);

    if (files.indexOf('package.json') !== -1) {
      const packageJson = await fs.readJson(
        path.join(directoryToSearch, 'package.json')
      );
      return packageJson.name;
    }

    directory = path.resolve(directory, '..');
  }

  throw new Error(`Unable to find package for: ${filepath}`);
}