<commit_before>_ = require 'underscore-plus'
path = require 'path'

module.exports =
class Builder
  constructor: ->
    @envPathKey = switch process.platform
      when 'win32' then 'Path'
      else 'PATH'

  run: (args, callback) -> undefined
  constructArgs: (filePath) -> undefined
  parseLogFile: (texFilePath) -> undefined

  constructChildProcessOptions: ->
    env = _.clone(process.env)
    env[@envPathKey] = childPath if childPath = @constructPath()
    options = env: env

  constructPath: ->
    texPath = atom.config.get('latex.texPath')?.trim()
    texPath = @defaultTexPath() unless texPath?.length
    processPath = process.env[@envPathKey]

    if match = texPath.match /^(.*)(\$PATH)(.*)$/
      texPath = "#{match[1]}#{processPath}#{match[3]}"
    else
      texPath = [texPath, processPath].join(path.delimiter)

  defaultTexPath: ->
    switch process.platform
      when 'win32'
        'C:\\texlive\\2014\\bin\\win32'
      else
        '/usr/texbin'

  resolveLogFilePath: (texFilePath) ->
    outputDirectory = atom.config.get('latex.outputDirectory') ? ''
    currentDirectory = path.dirname(texFilePath)
    fileName = path.basename(texFilePath).replace(/\.\w+$/, '.log')
    logFilePath = path.join(currentDirectory, outputDirectory, fileName)<commit_msg>Add support for MiKTeX 2.9<commit_after>_ = require 'underscore-plus'
path = require 'path'

module.exports =
class Builder
  constructor: ->
    @envPathKey = switch process.platform
      when 'win32' then 'Path'
      else 'PATH'

  run: (args, callback) -> undefined
  constructArgs: (filePath) -> undefined
  parseLogFile: (texFilePath) -> undefined

  constructChildProcessOptions: ->
    env = _.clone(process.env)
    env[@envPathKey] = childPath if childPath = @constructPath()
    options = env: env

  constructPath: ->
    texPath = atom.config.get('latex.texPath')?.trim()
    texPath = @defaultTexPath() unless texPath?.length
    processPath = process.env[@envPathKey]

    if match = texPath.match /^(.*)(\$PATH)(.*)$/
      texPath = "#{match[1]}#{processPath}#{match[3]}"
    else
      texPath = [texPath, processPath].join(path.delimiter)

  defaultTexPath: ->
    switch process.platform
      when 'win32'
        [
          'C:\\texlive\\2014\\bin\\win32'
          'C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64'
          'C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin'
        ].join(';')
      else
        '/usr/texbin'

  resolveLogFilePath: (texFilePath) ->
    outputDirectory = atom.config.get('latex.outputDirectory') ? ''
    currentDirectory = path.dirname(texFilePath)
    fileName = path.basename(texFilePath).replace(/\.\w+$/, '.log')
    logFilePath = path.join(currentDirectory, outputDirectory, fileName)
{'fraction_non_alphanumeric': 0.15314327485380116, 'fraction_numerical': 0.012426900584795321, 'mean_word_length': 3.1978527607361964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4509103', 'n_tokens_mistral': 889, 'n_tokens_neox': 855, 'n_words': 171}