<commit_before>'use strict';

const ora = require('ora');
const fs = require('fs');
const path = require('path');
const dotPingyTmpl = require('./dotPingyTmpl');

function createDotPingy(name) {
  const filename = '.pingy.json';
  const spinner = ora(`Creating ${filename}`).start();
  try {
    fs.writeFileSync(path.join(process.cwd(), filename), dotPingyTmpl(name), 'utf8');
  } catch (err) {
    spinner.fail(err);
    return;
  }
  spinner.succeed(`Created ${filename}`);
}

function updatePkgScripts(pkgJsonPath, answers) {
  const spinner = ora('Adding pingy scripts to package.json').start();
  try {
    const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
    pkgJson.scripts.start = 'pingy serve';
    pkgJson.scripts.export = 'pingy export';
    fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson));
    spinner.succeed('Pingy scripts added to package.json');
    createDotPingy(pkgJson.name, answers.exportDir);
  } catch (err) {
    spinner.fail(err);
  }
}

module.exports = updatePkgScripts;<commit_msg>`pingy serve` -> `pingy dev`<commit_after>'use strict';

const ora = require('ora');
const fs = require('fs');
const path = require('path');
const dotPingyTmpl = require('./dotPingyTmpl');

function createDotPingy(name) {
  const filename = '.pingy.json';
  const spinner = ora(`Creating ${filename}`).start();
  try {
    fs.writeFileSync(path.join(process.cwd(), filename), dotPingyTmpl(name), 'utf8');
  } catch (err) {
    spinner.fail(err);
    return;
  }
  spinner.succeed(`Created ${filename}`);
}

function updatePkgScripts(pkgJsonPath, answers) {
  const spinner = ora('Adding pingy scripts to package.json').start();
  try {
    const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
    pkgJson.scripts.start = 'pingy dev';
    pkgJson.scripts.export = 'pingy export';
    fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson));
    spinner.succeed('Pingy scripts added to package.json');
    createDotPingy(pkgJson.name, answers.exportDir);
  } catch (err) {
    spinner.fail(err);
  }
}

module.exports = updatePkgScripts;
{'fraction_non_alphanumeric': 0.15953868332532437, 'fraction_numerical': 0.0019221528111484864, 'mean_word_length': 4.657608695652174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2961768', 'n_tokens_mistral': 733, 'n_tokens_neox': 712, 'n_words': 140}