       @cliOutput.append data
       @scrollToBottom()
     try
-      @program = spawn cmd, args, stdio: 'pipe', env: process.env, cwd: @cwd
+      @program = spawn cmd, args, stdio: 'pipe', env: process.env, cwd: @getCwd()
       @program.stdout.pipe htmlStream
       @program.stderr.pipe htmlStream
       removeClass @statusIcon, 'status-success'


module.exports =
class CommandOutputView extends View

  @content: ->
    @div tabIndex: -1, class: 'panel cli-status panel-bottom', =>
      @div class: 'panel-heading', =>

    removeClass @statusIcon, 'status-success'
    addClass @statusIcon, 'status-error'

  getCwd: ()->
    @cwd or atom.project.path or @userHome

  spawn: (cmd, args) ->
    @cmdEditor.hide()
    htmlStream = ansihtml()
