<commit_before>#!/usr/bin/env node
'use strict'

const fs = require('fs')
const validator = require('html-validator')
const getHelpText = require('./lib/getHelpText')
const pkg = require('./package.json')
const query = process.argv[2]
const argv = require('minimist')((process.argv.slice(2)))
var options = {
  format: 'text',
  ignore: argv.ignore
}

const isError = item => item.type === 'error'

if (!query || process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
  console.log(getHelpText())
  process.exit(0)
}

if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
  console.log(pkg.version)
  process.exit(0)
}

if (query.indexOf('http') !== -1) {
  options.url = argv._[0]
}

if (argv.format && !argv.ignore) {
  options.format = argv.format
}

if (argv.url) {
  options.url = argv.url
}

if (argv.validator) {
  options.validator = argv.validator
}

if (argv.file) {
  options.data = fs.readFileSync(argv.file)
}

if (argv.data) {
  options.data = argv.data
}

validator(options, (error, data) => {
  if (error) {
    console.error(error)
    process.exitCode = 1
  } else {
    var errors
    var msg
    var validationFailed = false

    if (options.format === 'json') {
      errors = data.messages.filter(isError)
      msg = JSON.stringify(data, null, 2)
      if (errors.length > 0) {
        validationFailed = true
      }
    } else if (options.ignore) {
      msg = data
      if (data.includes('Error')) {
        validationFailed = true
      }
    } else {
      msg = data
      if (data.includes('There were errors')) {
        validationFailed = true
      }
    }
    if (validationFailed) {
      if (!argv.verbose) {
        console.log('Page is not valid')
        if (errors) {
          errors.forEach(err => {
            console.log(err)
          })
        }
      }
      process.exitCode = 1
    } else {
      if (!argv.verbose) {
        console.log('Page is valid')
      }
    }
    if (argv.verbose) {
      console.log(msg)
    }
  }
})<commit_msg>Revert "chore(index.js) add error messages if err"<commit_after>#!/usr/bin/env node
'use strict'

const fs = require('fs')
const validator = require('html-validator')
const getHelpText = require('./lib/getHelpText')
const pkg = require('./package.json')
const query = process.argv[2]
const argv = require('minimist')((process.argv.slice(2)))
var options = {
  format: 'text',
  ignore: argv.ignore
}

const isError = item => item.type === 'error'

if (!query || process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
  console.log(getHelpText())
  process.exit(0)
}

if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
  console.log(pkg.version)
  process.exit(0)
}

if (query.indexOf('http') !== -1) {
  options.url = argv._[0]
}

if (argv.format && !argv.ignore) {
  options.format = argv.format
}

if (argv.url) {
  options.url = argv.url
}

if (argv.validator) {
  options.validator = argv.validator
}

if (argv.file) {
  options.data = fs.readFileSync(argv.file)
}

if (argv.data) {
  options.data = argv.data
}

validator(options, (error, data) => {
  if (error) {
    console.error(error)
    process.exitCode = 1
  } else {
    var msg
    var validationFailed = false

    if (options.format === 'json') {
      const errors = data.messages.filter(isError)
      msg = JSON.stringify(data, null, 2)
      if (errors.length > 0) {
        validationFailed = true
      }
    } else if (options.ignore) {
      msg = data
      if (data.includes('Error')) {
        validationFailed = true
      }
    } else {
      msg = data
      if (data.includes('There were errors')) {
        validationFailed = true
      }
    }
    if (validationFailed) {
      if (!argv.verbose) {
        console.log('Page is not valid')
      }
      process.exitCode = 1
    } else {
      if (!argv.verbose) {
        console.log('Page is valid')
      }
    }
    if (argv.verbose) {
      console.log(msg)
    }
  }
})
{'fraction_non_alphanumeric': 0.16924227318045862, 'fraction_numerical': 0.006979062811565304, 'mean_word_length': 2.5513274336283187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5333417', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1363, 'n_words': 291}