<commit_before>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Build.Framework;

using Ncapsulate.Node.Tasks;

namespace Ncapsulate.Karma.Tasks
{
    /// <summary>
    /// 
    /// </summary>
    public class Karma : NcapsulateTask
    {
        public string ConfigFile { get; set; }

        public int Port { get; set; }

        public string LogLevel { get; set; }

        public string Reporters { get; set; }

        public string Browsers { get; set; }

        public int CaptureTimeout { get; set; }

        public int ReportSlowerThan { get; set; }

        /// <summary>
        /// Runs the task.
        /// </summary>
        /// <returns>
        /// true if successful; otherwise, false.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute()
        {
            var cmd = String.Format(CultureInfo.InvariantCulture, @"/c {0}\karma start --single-run", this.NodeDirectory);

            if (this.ConfigFile != null) cmd += " " + this.ConfigFile;
            if (this.Port > 0) cmd += " --port " + this.Port;
            if (this.CaptureTimeout > 0) cmd += " --capture-timeout " + this.CaptureTimeout;
            if (this.ReportSlowerThan > 0) cmd += " --report-slower-than " + this.ReportSlowerThan;
            if (this.LogLevel != null) cmd += " --log-level " + this.LogLevel;
            if (this.Browsers != null) cmd += " --browsers " + this.Browsers;
            if (this.Reporters != null) cmd += " --reporters " + this.Reporters;

            var output = Task.WhenAll(ExecWithOutputResultAsync(@"cmd", cmd)).Result.FirstOrDefault();

            if (output.StartsWith("ERROR"))
            {
                this.Log.LogError("karma start - error: " + output);<commit_msg>Fixed up comments in karma.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Build.Framework;

using Ncapsulate.Node.Tasks;

namespace Ncapsulate.Karma.Tasks
{
    /// <summary>
    /// 
    /// </summary>
    public class Karma : NcapsulateTask
    {
        /// <summary>
        /// Gets or sets the configuration file.
        /// </summary>
        /// <value>
        /// The configuration file.
        /// </value>
        public string ConfigFile { get; set; }

        /// <summary>
        /// Gets or sets the port.
        /// </summary>
        /// <value>
        /// The port.
        /// </value>
        public int Port { get; set; }

        /// <summary>
        /// Gets or sets the log level.
        /// </summary>
        /// <value>
        /// The log level.
        /// </value>
        public string LogLevel { get; set; }

        /// <summary>
        /// Gets or sets the reporters.
        /// </summary>
        /// <value>
        /// The reporters.
        /// </value>
        public string Reporters { get; set; }

        /// <summary>
        /// Gets or sets the browsers.
        /// </summary>
        /// <value>
        /// The browsers.
        /// </value>
        public string Browsers { get; set; }

        /// <summary>
        /// Gets or sets the capture timeout.
        /// </summary>
        /// <value>
        /// The capture timeout.
        /// </value>
        public int CaptureTimeout { get; set; }

        /// <summary>
        /// Gets or sets the report slower than.
        /// </summary>
        /// <value>
        /// The report slower than.
        /// </value>
        public int ReportSlowerThan { get; set; }

        /// <summary>
        /// Runs the task.
        /// </summary>
        /// <returns>
        /// true if successful; otherwise, false.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute()
        {
            var cmd = String.Format(CultureInfo.InvariantCulture, @"/c {0}\karma start --single-run", this.NodeDirectory);

            if (this.ConfigFile != null) cmd += " " + this.ConfigFile;
            if (this.Port > 0) cmd += " --port " + this.Port;
            if (this.CaptureTimeout > 0) cmd += " --capture-timeout " + this.CaptureTimeout;
            if (this.ReportSlowerThan > 0) cmd += " --report-slower-than " + this.ReportSlowerThan;
            if (this.LogLevel != null) cmd += " --log-level " + this.LogLevel;
            if (this.Browsers != null) cmd += " --browsers " + this.Browsers;
            if (this.Reporters != null) cmd += " --reporters " + this.Reporters;

            var output = Task.WhenAll(ExecWithOutputResultAsync(@"cmd", cmd)).Result.FirstOrDefault();

            if (output.StartsWith("ERROR"))
            {
                this.Log.LogError("karma start - error: " + output);
{'fraction_non_alphanumeric': 0.15098557203820362, 'fraction_numerical': 0.001625685836212152, 'mean_word_length': 1.6706456863809007, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 53, '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': '643772', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1366, 'n_words': 362}