<commit_before>'use babel'

import { BufferedProcess, BufferedNodeProcess } from 'atom'
import * as Path from 'path'
import * as FS from 'fs'
import * as TMP from 'tmp'
import { getPath } from 'consistent-path'

let NamedRegexp = null
export const FindCache = new Map()

// TODO: Remove this when electron upgrades node
const assign = Object.assign || function (target, source) {
  for (const key in source) {
    if (source.hasOwnProperty(key)) {
      target[key] = source[key]
    }
  }
  return target
}
const COMMAND_NOT_RECOGNIZED_MESSAGE = 'is not recognized as an internal or external command'

function _exec(command, args, opts, isNode) {
  const options = assign({
    env: assign({}, process.env),
    stream: 'stdout',
    throwOnStdErr: true
  }, opts)

  if (isNode) {
    delete options.env.OS
  }
  assign(options.env, { PATH: getPath() })

  return new Promise((resolve, reject) => {
    const data = { stdout: [], stderr: [] }
    const handleError = error => {
      if (error.code === 'EACCES' || (error.message && error.message.indexOf(COMMAND_NOT_RECOGNIZED_MESSAGE) !== -1)) {
        const newError = new Error(`Failed to spawn command '${command}'.` +
          ` Make sure it's a file, not a directory, and it's executable.`)
        newError.name = 'BufferedProcessError'
        reject(newError)
      }
      reject(error)
    }
    const parameters = {
      command,
      args,
      options,
      stdout: chunk => {
        data.stdout.push(chunk)
      },
      stderr: chunk => {
        data.stderr.push(chunk)
      },
      exit: () => {
        if (options.stream === 'stdout') {
          if (data.stderr.length && options.throwOnStdErr) {
            handleError(new Error(data.stderr.join('')))
          } else {
            resolve(data.stdout.join(''))
          }
        } else if (options.stream === 'stderr') {
          resolve(data.stderr.join(''))
        } else {
          resolve({ stdout: data.stdout.join(''), stderr: data.stderr.join('') })
        }
      }
    }
    const spawnedProcess = isNode ?
      new BufferedNodeProcess(parameters) :
      new BufferedProcess(parameters)

    spawnedProcess.onWillThrowError(({error}) => {
      handleError(error)
    })

    if (options.stdin) {
      try {
        spawnedProcess.process.stdin.write(options.stdin.toString())
        spawnedProcess.process.stdin.end()
      } catch (_) {
        // Do nothing
      }
    }
  })
}
<commit_msg>:shirt: Fix linting issues<commit_after>'use babel'

import { BufferedProcess, BufferedNodeProcess } from 'atom'
import * as Path from 'path'
import * as FS from 'fs'
import * as TMP from 'tmp'
import { getPath } from 'consistent-path'

let NamedRegexp = null
export const FindCache = new Map()

// TODO: Remove this when electron upgrades node
const assign = Object.assign || function (target, source) {
  for (const key in source) {
    if (source.hasOwnProperty(key)) {
      target[key] = source[key]
    }
  }
  return target
}
const COMMAND_NOT_RECOGNIZED_MESSAGE = 'is not recognized as an internal or external command'

function _exec(command, args, opts, isNode) {
  const options = assign({
    env: assign({}, process.env),
    stream: 'stdout',
    throwOnStdErr: true
  }, opts)

  if (isNode) {
    delete options.env.OS
  }
  assign(options.env, { PATH: getPath() })

  return new Promise((resolve, reject) => {
    const data = { stdout: [], stderr: [] }
    const handleError = error => {
      if (error.code === 'EACCES' ||
        (error.message && error.message.indexOf(COMMAND_NOT_RECOGNIZED_MESSAGE) !== -1)
      ) {
        const newError = new Error(`Failed to spawn command '${command}'.` +
          ` Make sure it's a file, not a directory, and it's executable.`)
        newError.name = 'BufferedProcessError'
        reject(newError)
      }
      reject(error)
    }
    const parameters = {
      command,
      args,
      options,
      stdout: chunk => {
        data.stdout.push(chunk)
      },
      stderr: chunk => {
        data.stderr.push(chunk)
      },
      exit: () => {
        if (options.stream === 'stdout') {
          if (data.stderr.length && options.throwOnStdErr) {
            handleError(new Error(data.stderr.join('')))
          } else {
            resolve(data.stdout.join(''))
          }
        } else if (options.stream === 'stderr') {
          resolve(data.stderr.join(''))
        } else {
          resolve({ stdout: data.stdout.join(''), stderr: data.stderr.join('') })
        }
      }
    }
    const spawnedProcess = isNode ?
      new BufferedNodeProcess(parameters) :
      new BufferedProcess(parameters)

    spawnedProcess.onWillThrowError(({ error }) => {
      handleError(error)
    })

    if (options.stdin) {
      try {
        spawnedProcess.process.stdin.write(options.stdin.toString())
        spawnedProcess.process.stdin.end()
      } catch (_) {
        // Do nothing
      }
    }
  })
}

{'fraction_non_alphanumeric': 0.13579246047831375, 'fraction_numerical': 0.00040535062829347385, 'mean_word_length': 2.4390243902439024, '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': '863293', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1509, 'n_words': 368}