<commit_before>ProjectRunnerView = require './project-runner-view'
shell = require 'shelljs'

fs = require('fs')

class ProjectRunnerBuildr

  constructor: ->
    shell.cd atom.project.path
    atom.config.setDefaults('project-runner', environmentVariables:'')

  command:(state) ->
    for file in shell.ls '*file'#|config.*
      if file is 'Makefile'
        return @make(state)
      if file is 'Rakefile'
        return @rake(state)

  make:(state) ->
    if state is 'run'
      return 'make run'
    return 'make test'

  rake:(state) ->
    if state is 'run'
      return 'rake run'
    return 'rake test --trace'

class ProjectRunner

  constructor: ->
    @runnerView = new ProjectRunnerView()
    @projectRunnerBuildr = new ProjectRunnerBuildr

  activate: ->
    atom.workspaceView.command 'project-runner:run',
      => @run( @projectRunnerBuildr.command('run') )
    atom.workspaceView.command 'project-runner:test',
      => @run( @projectRunnerBuildr.command('test') )

  deactivate: ->
    @runnerView.destroy()

  run: (script) ->
    if @runnerView.hasParent()
      @close()
      return

    if script is undefined
      @runnerView.show(false, 'no such file: Makefile or Rakefile\n')
      return

    environmentVariables = JSON.parse(atom.config.get("project-runner.environmentVariables"))
    for variable in environmentVariables.env
      variableSplit = variable.split('=')
      name = variableSplit[0]
      value = variableSplit[1]
      shell.env[name] = value

    @execute(script)

  close: ->
    @runnerView.close()

  execute: (cmd) ->
    shell.cd atom.project.path
    shell.exec cmd, (code, output) =>
      @runnerView.show(code is 0, output)
      @runnerView.scrollToBottom()

module.exports = new ProjectRunner<commit_msg>made environment variable config option more user friendly<commit_after>ProjectRunnerView = require './project-runner-view'
shell = require 'shelljs'

fs = require('fs')

class ProjectRunnerBuildr

  constructor: ->
    shell.cd atom.project.path
    atom.config.setDefaults('project-runner', environmentVariables:'')

  command:(state) ->
    for file in shell.ls '*file'#|config.*
      if file is 'Makefile'
        return @make(state)
      if file is 'Rakefile'
        return @rake(state)

  make:(state) ->
    if state is 'run'
      return 'make run'
    return 'make test'

  rake:(state) ->
    if state is 'run'
      return 'rake run'
    return 'rake test --trace'

class ProjectRunner

  constructor: ->
    @runnerView = new ProjectRunnerView()
    @projectRunnerBuildr = new ProjectRunnerBuildr

  activate: ->
    atom.workspaceView.command 'project-runner:run',
      => @run( @projectRunnerBuildr.command('run') )
    atom.workspaceView.command 'project-runner:test',
      => @run( @projectRunnerBuildr.command('test') )

  deactivate: ->
    @runnerView.destroy()

  run: (script) ->
    if @runnerView.hasParent()
      @close()
      return

    if script is undefined
      @runnerView.show(false, 'no such file: Makefile or Rakefile\n')
      return

    environmentVariables = JSON.parse('{"env":['+atom.config.get("project-runner.environmentVariables")+"]}")
    for variable in environmentVariables.env
      variableSplit = variable.split('=')
      name = variableSplit[0]
      value = variableSplit[1]
      shell.env[name] = value

    @execute(script)

  close: ->
    @runnerView.close()

  execute: (cmd) ->
    shell.cd atom.project.path
    shell.exec cmd, (code, output) =>
      @runnerView.show(code is 0, output)
      @runnerView.scrollToBottom()

module.exports = new ProjectRunner
{'fraction_non_alphanumeric': 0.12837649679754942, 'fraction_numerical': 0.001670843776106934, 'mean_word_length': 3.1098398169336385, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 29, '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': '1520098', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1064, 'n_words': 260}