<commit_before>const path = require('path');
const fs = require('fs');

const cwdPath = (file) =>
  path.join(process.env['INIT_CWD'] || process.cwd(), file);

const getConfig = () => {
  const packageJsonFilename = cwdPath('package.json');
  const packageJson = require(packageJsonFilename);
  return packageJson['geolite2'] || {};<commit_msg>fix: Gracefully treat missing package.json<commit_after>const path = require('path');
const fs = require('fs');

const cwdPath = (file) =>
  path.join(process.env['INIT_CWD'] || process.cwd(), file);

const getConfig = () => {
  const packageJsonFilename = cwdPath('package.json');

  try {
    const packageJson = require(packageJsonFilename);
    return packageJson['geolite2'] || {};
  } catch {
    console.log(
      "WARN: geolite2 cannot find project's package.json file, using default configuration.\n" +
        'WARN: geolite2 expects to have maxmind licence key to be present in `MAXMIND_LICENSE_KEY` env variable when package.json is unavailable.'
    );
    console.log(
      'WARN: geolite2 expected package.json to be preset at:\n%s',
      packageJsonFilename
    );
    return {};
  }
{'fraction_non_alphanumeric': 0.14223385689354276, 'fraction_numerical': 0.004363001745200698, 'mean_word_length': 4.237442922374429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '579634', 'n_tokens_mistral': 350, 'n_tokens_neox': 340, 'n_words': 92}