<commit_before>const crypto = require('crypto');
const childProcess = require('child_process');
const fs = require('fs');
const os = require('os');

const config = require('./config');

const exec = childProcess.exec;
const execFileSync = childProcess.execFileSync;

function hasFlag(flag) {
	return !!process.argv.find((arg) => arg === '--' + flag);
}

function getOption(name) {
	const index = process.argv.findIndex((arg) => arg === '--' + name);
	if (index > -1) {
		return process.argv[index + 1];
	}
	return null;
}

const utils = {
	DELETED: 'DELETED',
	DRY_RUN: hasFlag('dry'),
	DEV: process.env.BACKUP_ENV === 'dev',
	TEST: process.env.BACKUP_ENV === 'test',
	VERBOSE: hasFlag('verbose'),

	hasFlag: hasFlag,
	getOption: getOption,

	execPromise: (bin, args, printOutput) => {
		return new Promise((resolve, reject) => {
			const child = exec([bin].concat(args).map(utils.escape).join(' '));

			let stdout = '';
			let stderr = '';
			child.stdout.on('data', (data) => {
				stdout += data;
				if (printOutput) {
					console.log(data);
				}<commit_msg>fix: Config check support for custom shell commands :bug:<commit_after>const crypto = require('crypto');
const childProcess = require('child_process');
const fs = require('fs');
const os = require('os');

const config = require('./config');

const exec = childProcess.exec;
const execFileSync = childProcess.execFileSync;

function hasFlag(flag) {
	return !!process.argv.find((arg) => arg === '--' + flag);
}

function getOption(name) {
	const index = process.argv.findIndex((arg) => arg === '--' + name);
	if (index > -1) {
		return process.argv[index + 1];
	}
	return null;
}

const utils = {
	DELETED: 'DELETED',
	DRY_RUN: hasFlag('dry'),
	DEV: process.env.BACKUP_ENV === 'dev',
	TEST: process.env.BACKUP_ENV === 'test',
	VERBOSE: hasFlag('verbose'),

	hasFlag: hasFlag,
	getOption: getOption,

	execPromise: (bin, args, printOutput) => {
		return new Promise((resolve, reject) => {
			const cmd = bin.split(' ').concat(args).map(utils.escape).join(' ');
			const child = exec(cmd);

			let stdout = '';
			let stderr = '';
			child.stdout.on('data', (data) => {
				stdout += data;
				if (printOutput) {
					console.log(data);
				}
{'fraction_non_alphanumeric': 0.1861098502042669, 'fraction_numerical': 0.0018157058556513845, 'mean_word_length': 4.19811320754717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6383084', 'n_tokens_mistral': 803, 'n_tokens_neox': 745, 'n_words': 176}