{"size": 933, "ext": "js", "max_stars_repo_path": "lib/utils/reporters/fancy.js", "max_stars_repo_name": "njam/nuxt-generate-cluster", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/utils/reporters/fancy.js", "max_issues_repo_name": "njam/nuxt-generate-cluster", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/utils/reporters/fancy.js", "max_forks_repo_name": "njam/nuxt-generate-cluster", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.9230769231, "max_line_length": 79, "alphanum_fraction": 0.6195069668}
import { FancyReporter } from 'consola/dist/consola.cjs.js'
import messaging from '../messaging'

// Consola Reporter
export default class Reporter extends FancyReporter {
  constructor(options) {
    super(options)

    /* istanbul ignore next */
    messaging.on('consola', ({ logObj, stream }) => {
      logObj.date = new Date(logObj.date)

      this.superLog(logObj, {
        async: stream.async,
        stdout: process.stdout,
        stderr: process.stderr
      })
    })
  }

  superLog(logObj, stream) {
    /* istanbul ignore next */
    super.log(logObj, stream)
  }

  log(logObj, { async } = {}) {
    if (logObj.type === 'success' && logObj.args[0].startsWith('Generated ')) {
      // Ignore success messages from Nuxt.Generator::generateRoute
      return
    }

    if (global._ngc_log_tag) {
      logObj.tag = global._ngc_log_tag
    }

    messaging.send(null, 'consola', { logObj, stream: { async } })
  }
}
