// @flow

const { dim, green, magenta, red } = require('chalk')
const Formatter = require('./formatter')
const path = require('path')
const printCodeFrame = require('../helpers/print-code-frame')

class DetailedFormatter extends Formatter {
  // A detailed formatter, prints output before the step name

  error (errorMessage: string) {
    super.error(errorMessage)
    console.log(dim(this.output))
    console.log(
      red(
        `${this.activity.file}:${this.activity.line} ${
          this.title
        } -- ${errorMessage}`
      )
    )
    const filePath = path.join(this.configuration.sourceDir, this.activity.file)
    printCodeFrame(console.log, filePath, this.activity.line)
  }

  skip (message: string) {
    super.skip(message)
    console.log(dim(this.output))
    console.log(
      magenta(`${this.activity.file}:${this.activity.line} -- ${message}`)
    )
  }

  success () {
    super.success()
    console.log(dim(this.output))
    console.log(
      green(`${this.activity.file}:${this.activity.line} -- ${this.title}`)
    )
  }

  warning (warningMessage: string) {
    super.warning(warningMessage)
    console.log(dim(this.output))
    console.log(
      magenta(
        `${this.activity.file}:${this.activity.line} ${
          this.title
        } -- ${warningMessage}`
      )
    )
  }
}

module.exports = DetailedFormatter

@@ -1245,42 +1245,8 @@
 ine%7D
- $%7B%0A          this.title%0A        %7D
  -- 

Fix external links