<commit_before>import Promise from 'bluebird'
import process from 'process'
import path from 'path'

import {application as app} from 'nxus-core'

/**
 * Start a test server
 */

let waiting

export default function startTestServer(script="index.js", env={}) {

  if (waiting) {
    return waiting
  }
  
  waiting = new Promise((resolve, reject) => {
    let cwd = process.cwd()
    let p = path.resolve(cwd, script)

    process.env.PORT = "3002"
    for (let k in env) {
      process.env[k] = env[k]
    }
    let application = require(p)
    app.onceAfter("launch", () => {
      resolve()
    })
  })
  return waiting
}<commit_msg>simpler<commit_after>import Promise from 'bluebird'
import process from 'process'
import path from 'path'

import {application} from 'nxus-core'

/**
 * Start a test server
 */

let waiting

export default function startTestServer(script="index.js", env={}) {

  if (waiting) {
    return waiting
  }
  
  waiting = new Promise((resolve, reject) => {
    let cwd = process.cwd()
    let p = path.resolve(cwd, script)

    process.env.PORT = "3002"
    for (let k in env) {
      process.env[k] = env[k]
    }
    require(p)
    application.onceAfter("launch", () => {
      resolve()
    })
  })
  return waiting
}
{'fraction_non_alphanumeric': 0.13828936850519585, 'fraction_numerical': 0.006394884092725819, 'mean_word_length': 2.962025316455696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5065931', 'n_tokens_mistral': 423, 'n_tokens_neox': 413, 'n_words': 116}