<commit_before>/**
 * Npm module for Unicode CLDR JSON data
 *
 * Copyright 2013 <NAME>
 * Released under the MIT license
 * https://github.com/rxaviers/cldr-data-npm/blob/master/LICENSE-MIT
 */

"use strict";

var cldrDownloader = require("cldr-data-downloader");
var path = require("path");
var urls = require("./urls");
var parentPackage;
var url;

try {
  parentPackage = require("../../package.json");
}
catch(error) {}

url = urls[process.env.CLDR_COVERAGE || "core"];

if (parentPackage) {
  if (parentPackage["cldr-data-coverage"] && parentPackage.dependencies["cldr-data"]) {
    if (!/^full|core$/.test(parentPackage["cldr-data-coverage"])) {
      throw new TypeError("Your `cldr-data-coverage` setting must have the value \"core\" or \"full\".");
    }
    url = urls[parentPackage["cldr-data-coverage"]];
  }
}

if (process.env.CLDR_URL) {
  url = url.replace(
    "http://www.unicode.org/Public/cldr",
    process.env.CLDR_URL.replace(/\/$/, "")
  );
}

cldrDownloader(
  url,
  __dirname,
  function(error) {
    if (error) {
      if (/E_ALREADY_INSTALLED/.test(error.code)) {
        error.message = error.message.replace(/Use `options.*/, "Use -f to " +
          "override.");
        return console.log(error.message);
      } else {
        console.error("Whops", error.message);
        process.exit(1);
      }
    }
  }
);<commit_msg>Installer to pass urls.json to downloader to parse + others<commit_after>/**
 * Npm module for Unicode CLDR JSON data
 *
 * Copyright 2013 <NAME>
 * Released under the MIT license
 * https://github.com/rxaviers/cldr-data-npm/blob/master/LICENSE-MIT
 */

"use strict";

var coverage, parentPackage, srcUrl;

var cldrDownloader = require("cldr-data-downloader");
var path = require("path");

var options = {};

if (process.env.CLDR_URL) {
  srcUrl = srcUrl.replace(
    "http://www.unicode.org/Public/cldr",
    process.env.CLDR_URL.replace(/\/$/, "")
  );

} else {

  srcUrl = path.join(__dirname, "./urls.json");

  try {
    parentPackage = require("../../package.json");
    if (parentPackage["cldr-data-coverage"] && parentPackage.dependencies["cldr-data"]) {
      coverage = parentPackage["cldr-data-coverage"];
    }
  }
  catch(error) {}

  if (process.env.CLDR_COVERAGE) {
    coverage = process.env.CLDR_COVERAGE;
  }

  if (coverage) {
    options.srcUrlKey = coverage;
  }
}

cldrDownloader(
  srcUrl,
  __dirname,
  options,
  function(error) {
    if (error) {
      if (/E_ALREADY_INSTALLED/.test(error.code)) {
        error.message = error.message.replace(/Use `options.*/, "Use -f to " +
          "override.");
        return console.log(error.message);
      } else {
        console.error("Whops", error.message);
        process.exit(1);
      }
    }
  }
);
{'fraction_non_alphanumeric': 0.17275383491599708, 'fraction_numerical': 0.003652300949598247, 'mean_word_length': 3.0220264317180616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4168518', 'n_tokens_mistral': 980, 'n_tokens_neox': 957, 'n_words': 175}