<commit_before>/*eslint no-console: ["error", {allow: ["log"]}] */

import validate from './index.js'

const format = validate.consoleFormat
import colors from 'colors/safe'
import fs from 'fs'
import remoteFiles from './utils/files/remoteFiles'

const exitProcess = issues => {
  if (
    issues === 'Invalid' ||
    (issues.errors && issues.errors.length >= 1) ||
    (issues.config && issues.config.length >= 1)
  ) {
    process.exit(1)
  } else {
    process.exit(0)
  }
}

const errorToString = err => {
  if (err instanceof Error) return err.stack
  else if (typeof err === 'object') return JSON.parse(err)
  else return err
}

/**
 * Write a large string or buffer to stdout and wait for the drain event
 *
 * This is needed to avoid truncating buffered output when piped
 * @param {string} data
 * @param {function} cb
 */
const writeStdout = (data, cb) => {
  if (!process.stdout.write(data)) {
    process.stdout.once('drain', cb)
  } else {
    process.nextTick(cb)
  }
}

export default function(dir, options) {
  process.on('unhandledRejection', err => {
    console.log(
      format.unexpectedError(
        // eslint-disable-next-line
        `Unhandled rejection (\n  reason: ${errorToString(err)}\n).\n`,
      ),
    )
    process.exit(3)
  })

  if (fs.existsSync(dir)) {
    if (options.json) {
      validate.BIDS(dir, options, function(issues, summary) {
        writeStdout(JSON.stringify({ issues, summary }), () =>
          exitProcess(issues),
        )
      })
    } else {
      validate.BIDS(dir, options, function(issues, summary) {
        console.log(format.issues(issues, options) + '\n')
        console.log(format.summary(summary, options))
        exitProcess(issues)
      })
    }
  } else {
    console.log(colors.red(dir + ' does not exist'))
    process.exit(2)
  }
}
<commit_msg>meaningless change to cause difference in package<commit_after>/*eslint no-console: ["error", {allow: ["log"]}] */

import validate from './index.js'

const format = validate.consoleFormat
import colors from 'colors/safe'
import fs from 'fs'
import remoteFiles from './utils/files/remoteFiles'

const exitProcess = issues => {
  if (
    issues === 'Invalid' ||
    (issues.errors && issues.errors.length >= 1) ||
    (issues.config && issues.config.length >= 1)
  ) {
    process.exit(1)
  } else {
    process.exit(0)
  }
}

const errorToString = err => {
  if (err instanceof Error) return err.stack
  else if (typeof err === 'object') return JSON.parse(err)
  else return err
}

/**
 * Write a large string or buffer to stdout and wait for the drain event
 *
 * This is needed to avoid truncating buffered output when piped
 * @param {string} data
 * @param {function} cb
 */
const writeStdout = (data, cb) => {
  if (!process.stdout.write(data)) {
    process.stdout.once('drain', cb)
  } else {
    process.nextTick(cb)
  }
}

export default function(dir, options) {
  process.on('unhandledRejection', err => {
    console.log(
      format.unexpectedError(
        // eslint-disable-next-line
        `Unhandled rejection (\n  reason: ${errorToString(err)}\n).\n`,
      ),
    )
    process.exit(3)
  })

  if (fs.existsSync(dir)) {
    if (options.json) {
      validate.BIDS(dir, options, function(issues, summary) {
        writeStdout(JSON.stringify({ issues, summary }), () =>
          exitProcess(issues),
        )
      })
    } else {
      validate.BIDS(dir, options, function(issues, summary) {
        console.log(format.issues(issues, options) + '\n')
        console.log(format.summary(summary, options))
        exitProcess(issues)
      })
    }
  } else {
    console.log(colors.red(dir + ' does not exist '))
    process.exit(2)
  }
}

{'fraction_non_alphanumeric': 0.14917276918904257, 'fraction_numerical': 0.0032546786004882017, 'mean_word_length': 2.8985200845665964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2185855', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1162, 'n_words': 290}