<commit_before>import Tapable from 'tappable'
import chalk from 'chalk'
import { Options } from 'common'
import ModuleContainer from './module'
import Renderer from './renderer'
import Debug from 'debug'
import enableDestroy from 'server-destroy'
import Module from 'module'
import { join, resolve } from 'path'

const debug = Debug('nuxt:')
debug.color = 5

export default class Nuxt extends Tapable {
  constructor (_options = {}) {
    super()

    this.options = Options(_options)

    // Paths for resolving requires from `rootDir`
    this.nodeModulePaths = Module._nodeModulePaths(this.options.rootDir)

    this.initialized = false
    this.errorHandler = this.errorHandler.bind(this)

    // Create instance of core components
    this.moduleContainer = new ModuleContainer(this)
    this.renderer = new Renderer(this)

    // Backward compatibility
    this.render = this.renderer.app
    this.renderRoute = this.renderer.renderRoute.bind(this.renderer)
    this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(this.renderer)

    this._ready = this.ready().catch(this.errorHandler)
  }

  async ready () {
    if (this._ready) {
      return this._ready
    }

    await this.moduleContainer._ready()
    await this.applyPluginsAsync('ready')
    await this.renderer._ready()

    this.initialized = true
    return this
  }

  listen (port = 3000, host = 'localhost') {
    return new Promise((resolve, reject) => {
      const server = this.renderer.app.listen({ port, host, exclusive: false }, err => {
        /* istanbul ignore if */
        if (err) {
          return reject(err)
        }

        // Show Open URL
        let _host = host === '0.0.0.0' ? 'localhost' : host
        // eslint-disable-next-line no-console
        console.log('\n' + chalk.bold(chalk.bgBlue.black(' OPEN ') + chalk.blue(` http://${_host}:${port}\n`)))

        // Close server on nuxt close<commit_msg>green OPEN message<commit_after>import Tapable from 'tappable'
import chalk from 'chalk'
import { Options } from 'common'
import ModuleContainer from './module'
import Renderer from './renderer'
import Debug from 'debug'
import enableDestroy from 'server-destroy'
import Module from 'module'
import { join, resolve } from 'path'

const debug = Debug('nuxt:')
debug.color = 5

export default class Nuxt extends Tapable {
  constructor (_options = {}) {
    super()

    this.options = Options(_options)

    // Paths for resolving requires from `rootDir`
    this.nodeModulePaths = Module._nodeModulePaths(this.options.rootDir)

    this.initialized = false
    this.errorHandler = this.errorHandler.bind(this)

    // Create instance of core components
    this.moduleContainer = new ModuleContainer(this)
    this.renderer = new Renderer(this)

    // Backward compatibility
    this.render = this.renderer.app
    this.renderRoute = this.renderer.renderRoute.bind(this.renderer)
    this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(this.renderer)

    this._ready = this.ready().catch(this.errorHandler)
  }

  async ready () {
    if (this._ready) {
      return this._ready
    }

    await this.moduleContainer._ready()
    await this.applyPluginsAsync('ready')
    await this.renderer._ready()

    this.initialized = true
    return this
  }

  listen (port = 3000, host = 'localhost') {
    return new Promise((resolve, reject) => {
      const server = this.renderer.app.listen({ port, host, exclusive: false }, err => {
        /* istanbul ignore if */
        if (err) {
          return reject(err)
        }

        // Show Open URL
        let _host = host === '0.0.0.0' ? 'localhost' : host
        // eslint-disable-next-line no-console
        console.log('\n' + chalk.bold(chalk.bgGreen.white(' OPEN ') + chalk.green(` http://${_host}:${port}\n`)))

        // Close server on nuxt close
{'fraction_non_alphanumeric': 0.12151238591916558, 'fraction_numerical': 0.00469361147327249, 'mean_word_length': 3.050686378035903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1727002', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1120, 'n_words': 295}