<commit_before>package com.emberjs.cli

import com.emberjs.utils.waitFor
import com.intellij.execution.configurations.GeneralCommandLine
import org.apache.commons.lang.SystemUtils
import java.io.BufferedReader
import java.util.concurrent.TimeUnit

class EmberCli(vararg val parameters: String) {

    var workDirectory: String? = null

    fun run(): BufferedReader {
        val suffix = when {
            SystemUtils.IS_OS_WINDOWS -> ".cmd"
            else -> ""
        }

        // complicated invocation due to IntelliJ 14 compat
        val workDir = workDirectory
        val process = GeneralCommandLine("node_modules/.bin/ember$suffix").apply {
            addParameters(*parameters)
            withWorkDirectory(workDir)
        }.createProcess()

        YesThread(process).start()

        if (!process.waitFor(10, TimeUnit.SECONDS)) {
            process.destroy()
            throw Exception("Process timed out. Please try again on the command line.")
        }

        val exitValue = process.exitValue()
        if (exitValue != 0) {
            throw Exception("Process did not exit properly (code = $exitValue). Please try again on the command line.")
        }

        return process.inputStream.bufferedReader()
    }

    companion object {
        val BLUEPRINTS = mapOf(
                Pair("acceptance-test", "Acceptance Test"),
                Pair("adapter", "Adapter"),
                Pair("adapter-test", "Adapter Test"),
                Pair("component", "Component"),
                Pair("component-test", "Component Test"),
                Pair("controller", "Controller"),<commit_msg>Too short timeout<commit_after>package com.emberjs.cli

import com.emberjs.utils.waitFor
import com.intellij.execution.configurations.GeneralCommandLine
import org.apache.commons.lang.SystemUtils
import java.io.BufferedReader
import java.util.concurrent.TimeUnit

class EmberCli(vararg val parameters: String) {

    var workDirectory: String? = null

    fun run(): BufferedReader {
        val suffix = when {
            SystemUtils.IS_OS_WINDOWS -> ".cmd"
            else -> ""
        }

        // complicated invocation due to IntelliJ 14 compat
        val workDir = workDirectory
        val process = GeneralCommandLine("node_modules/.bin/ember$suffix").apply {
            addParameters(*parameters)
            withWorkDirectory(workDir)
        }.createProcess()

        YesThread(process).start()

        if (!process.waitFor(30, TimeUnit.SECONDS)) {
            process.destroy()
            throw Exception("Process timed out. Please try again on the command line.")
        }

        val exitValue = process.exitValue()
        if (exitValue != 0) {
            throw Exception("Process did not exit properly (code = $exitValue). Please try again on the command line.")
        }

        return process.inputStream.bufferedReader()
    }

    companion object {
        val BLUEPRINTS = mapOf(
                Pair("acceptance-test", "Acceptance Test"),
                Pair("adapter", "Adapter"),
                Pair("adapter-test", "Adapter Test"),
                Pair("component", "Component"),
                Pair("component-test", "Component Test"),
                Pair("controller", "Controller"),
{'fraction_non_alphanumeric': 0.10510141364474493, 'fraction_numerical': 0.003073140749846343, 'mean_word_length': 2.3248212461695608, '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': '2224686', 'n_tokens_mistral': 863, 'n_tokens_neox': 804, 'n_words': 211}