<commit_before>'use strict';

const { createInterface } = require('readline');
const { loadJSON, saveJSON } = require('./utils/json');

function loadConfig() {
	try {
		return loadJSON('config.json');
	} catch (err) {
		return {
			token: 'token'
		};
	}
}
async function validateConfig(input, config) {
	config = Object.assign({}, config);
	for (const key in config) {
		while (config[key] === key || config[key] === '') {
			console.log('Enter ' + key + ': ');
			/* eslint no-await-in-loop: "off" */
			config[key] = (await input()).trim();
		}
	}
	return config;
}

const rl = createInterface({ input: process.stdin });

const line = () =>
	new Promise(resolve =>
		rl.once('line', resolve));

validateConfig(line, loadConfig()).then(config =>
	(saveJSON('config.json', config),
		rl.close(),<commit_msg>init fix<commit_after>'use strict';

const { existsSync, mkdirSync } = require('fs');
const { createInterface } = require('readline');
const { loadJSON, saveJSON } = require('./utils/json');

function dirs() {
	if (!existsSync('data')) {
		mkdirSync('data');
	}
}

function loadConfig() {
	try {
		return loadJSON('config.json');
	} catch (err) {
		return {
			token: 'token'
		};
	}
}

async function validateConfig(input, config) {
	config = Object.assign({}, config);
	for (const key in config) {
		while (config[key] === key || config[key] === '') {
			console.log('Enter ' + key + ': ');
			/* eslint no-await-in-loop: "off" */
			config[key] = (await input()).trim();
		}
	}
	return config;
}

const rl = createInterface({ input: process.stdin });

const line = () =>
	new Promise(resolve =>
		rl.once('line', resolve));

dirs();

validateConfig(line, loadConfig()).then(config =>
	(saveJSON('config.json', config),
		rl.close(),
{'fraction_non_alphanumeric': 0.2019506597819851, 'fraction_numerical': 0.0, 'mean_word_length': 4.129411764705883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5666479', 'n_tokens_mistral': 620, 'n_tokens_neox': 589, 'n_words': 132}