<commit_before>const execS = require('child_process').exec
const { replaceSpaceCharacters, createOutputFileName } = require('./helpers/util')

const convert = ({ files, outputPath, outputType, name }) => {
  // eslint-disable-next-line dot-notation
  process.env['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

  return new Promise((resolve, reject) => {
    execS('which convert', (error) => {
      if (error) reject(error)

      const outputName = name || createOutputFileName(outputType)(files)
      const command = [
        'convert',
        ...files.map(replaceSpaceCharacters), // input files
        outputPath + outputName
      ].join(' ')

      console.log(command)

      execS(command, (error) => {
        if (error) reject(error)
        else resolve(outputName)
      })
    })
  })
}

const installImageMagick = () => {
  return new Promise((resolve, reject) => {
    execS('which brew', (error) => {
      if (error) return reject(new Error('Brew is required to run Alchemy. Please visit https://brew.sh/ to install.'))
      return execS('which convert', (error) => {
        if (error) {
          return execS('brew install imagemagick', (error) => {
            return error ? reject(error) : resolve('ImageMagick is installed.')
          })
        }
        return resolve('ImageMagick already installed.')
      })
    })
  })
}

module.exports = {
  convert,
  installImageMagick
}<commit_msg>Clean up<commit_after>const execS = require('child_process').exec
const { replaceSpaceCharacters, createOutputFileName } = require('./helpers/util')

const convert = ({ files, outputPath, outputType, name }) => {
  // eslint-disable-next-line dot-notation
  process.env['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

  return new Promise((resolve, reject) => {
    execS('which convert', (error) => {
      if (error) reject(error)

      const outputName = name || createOutputFileName(outputType)(files)
      const command = [
        'convert',
        ...files.map(replaceSpaceCharacters), // input files
        outputPath + outputName
      ].join(' ')

      console.log(command)

      return execS(command, err => (err ? reject(err) : resolve(outputName)))
    })
  })
}

const installImageMagick = () => {
  return new Promise((resolve, reject) => {
    execS('which brew', (error) => {
      if (error) return reject(new Error('Brew is required to run Alchemy. Please visit https://brew.sh/ to install.'))
      return execS('which convert', (error) => {
        if (error) {
          return execS('brew install imagemagick', (error) => {
            return error ? reject(error) : resolve('ImageMagick is installed.')
          })
        }
        return resolve('ImageMagick already installed.')
      })
    })
  })
}

module.exports = {
  convert,
  installImageMagick
}
{'fraction_non_alphanumeric': 0.15172900494001412, 'fraction_numerical': 0.0, 'mean_word_length': 2.8466757123473543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '2579525', 'n_tokens_mistral': 840, 'n_tokens_neox': 822, 'n_words': 192}