<commit_before>// Shebang will be added by webpack
//#!/usr/bin/env node --harmony

const
    VERSION = require('../package.json').version,
    fs = require('fs'),
    program = require('commander'),
    validate = require('./index').default;

program
    .version(VERSION)
    .arguments('<filePath>')
    .description('Validate embedded examples in Swagger-JSONs')
    .action(filePath => {
        const
            jsonSchema = JSON.parse(fs.readFileSync(filePath, 'utf-8')),
            result = validate(jsonSchema);
        if (result.valid) { return; }
        process.stderr.write(JSON.stringify(result.errors, null, '    '));
    });
program.parse(process.argv);
<commit_msg>chore(cli): exit with error, when validation fails<commit_after>// Shebang will be added by webpack
//#!/usr/bin/env node --harmony

const
    VERSION = require('../package.json').version,
    fs = require('fs'),
    program = require('commander'),
    validate = require('./index').default;

program
    .version(VERSION)
    .arguments('<filePath>')
    .description('Validate embedded examples in Swagger-JSONs')
    .action(filePath => {
        const
            jsonSchema = JSON.parse(fs.readFileSync(filePath, 'utf-8')),
            result = validate(jsonSchema);
        if (result.valid) { return; }
        process.stderr.write(JSON.stringify(result.errors, null, '    '));
        process.exit(1);
    });
program.parse(process.argv);

{'fraction_non_alphanumeric': 0.15921787709497207, 'fraction_numerical': 0.002094972067039106, 'mean_word_length': 2.926027397260274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6555110', 'n_tokens_mistral': 424, 'n_tokens_neox': 419, 'n_words': 87}