<commit_before>#! /usr/bin/env node
const fs = require("fs");
const path = require("path");
const colors = {
  "red"    : "\x1b[31m",
  "green"  : "\x1b[32m",
  "yellow" : "\x1b[33m",
  "blue"   : "\x1b[34m",
  "magenta": "\x1b[35m",
  "cyan"   : "\x1b[36m",
  "default": "\x1b[0m"
};


// Check if package.json exists
// Create file if false exist
if (! fs.existsSync("package.json")) {
  try {
    console.log(colors.yellow, "!", colors.default, "package.json doesn’t exist. One has been created.");
    fs.writeFileSync("package.json", "{}", "utf8");
  }
  catch(error) {
    console.log(error);
    process.exit(1);
  }
}


// Try to get and validate package.json
try {
  try {
    JSON.parse(fs.readFileSync("package.json", "utf8"));
  }
  catch(error) {
    console.log(colors.red, "✘", colors.default, "Invalid JSON in package.json");
    process.exit(1);
  }
}
catch(error) {
  console.log(error);<commit_msg>Empty line at the end of new package.json.<commit_after>#! /usr/bin/env node
const fs = require("fs");
const path = require("path");
const colors = {
  "red"    : "\x1b[31m",
  "green"  : "\x1b[32m",
  "yellow" : "\x1b[33m",
  "blue"   : "\x1b[34m",
  "magenta": "\x1b[35m",
  "cyan"   : "\x1b[36m",
  "default": "\x1b[0m"
};


// Check if package.json exists
// Create file if false exist
if (! fs.existsSync("package.json")) {
  try {
    console.log(colors.yellow, "!", colors.default, "package.json doesn’t exist. One has been created.");
    fs.writeFileSync("package.json", "{}\n", "utf8");
  }
  catch(error) {
    console.log(error);
    process.exit(1);
  }
}


// Try to get and validate package.json
try {
  try {
    JSON.parse(fs.readFileSync("package.json", "utf8"));
  }
  catch(error) {
    console.log(colors.red, "✘", colors.default, "Invalid JSON in package.json");
    process.exit(1);
  }
}
catch(error) {
  console.log(error);
{'fraction_non_alphanumeric': 0.20750670241286864, 'fraction_numerical': 0.025737265415549597, 'mean_word_length': 3.3094688221709005, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '1722225', 'n_tokens_mistral': 747, 'n_tokens_neox': 728, 'n_words': 151}