   serialize: -> undefined
 
   createOutputPanel: ->
+    # Create output panel (or return if already exists)
     unless @messages?
       @messages = new MessagePanelView
         title: 'Pawn output'

    return @messages

  build: ->
    filepath = atom.workspace.getActiveTextEditor()?.getPath()

    # ignore command if current file is not saved, or is not a .pwn file
    return unless filepath? and path.extname(filepath) == '.pwn'

    # prepare command
    cmd = atom.config.get('pawn-build.pawnExecutablePath')

    # prepare arguments
    args = atom.config.get('pawn-build.pawnOptions')
    args.push path.basename filepath

    # run pawn
    process = child_process.spawn cmd, args,
      cwd: path.dirname filepath

    procout = []
    hasError = false

    process.stdout.on 'data', (data) ->
      procout.push data.toString()

    process.stderr.on 'data', (data) ->
      procout.push data.toString()

    process.on 'error', (error) =>
      hasError = true
      output = @createOutputPanel()
      output.add new PlainMessageView

  messages: null
  subscriptions: null

  # Configuration options
  config:
    # Path to pawncc executable
    pawnExecutablePath:
      title: 'Path to pawncc executable'
      type: 'string'
      default: 'C:\\pawn\\pawncc.exe'

    # List of pawncc options (passed before filename)
    pawnOptions:
      title: 'Pawn options'
      type: 'array'
