<commit_before>﻿[<AutoOpen>]
/// Contains functions which can be used to start other tools.
module Fake.ProcessHelper

open System
open System.ComponentModel
open System.Diagnostics
open System.IO
open System.Threading
open System.Text
open System.Collections.Generic
open System.Collections.Concurrent
open System.ServiceProcess


/// If set to true the ProcessHelper will start all processes with a custom ProcessEncoding.
/// If set to false (default) only mono processes will be changed.
let mutable AlwaysSetProcessEncoding = false

/// The ProcessHelper will start all processes with this encoding if AlwaysSetProcessEncoding is set to true.
/// If AlwaysSetProcessEncoding is set to false (default) only mono processes will be changed.
let mutable ProcessEncoding = Encoding.UTF8

/// [omit]
type internal ConcurrentBag<'T> with
    member internal this.Clear() =
        while not(this.IsEmpty) do
            this.TryTake() |> ignore

/// [omit]
let startedProcesses = ConcurrentBag()

/// [omit]
let start (proc : Process) =
    if isMono || AlwaysSetProcessEncoding then
        try
            System.Console.OutputEncoding <- ProcessEncoding
        with exn ->
            logfn "Failed setting UTF8 console encoding, ignoring error... %s." exn.Message

    if isMono && proc.StartInfo.FileName.ToLowerInvariant().EndsWith(".exe") then
        proc.StartInfo.Arguments <- "--debug \"" + proc.StartInfo.FileName + "\" " + proc.StartInfo.Arguments
        proc.StartInfo.FileName <- monoPath

    proc.Start() |> ignore
    startedProcesses.Add(proc.Id, proc.StartTime) |> ignore

/// [omit]
let mutable redirectOutputToTrace = false

/// [omit]
let mutable enableProcessTracing = true

/// A record type which captures console messages
type ConsoleMessage =
    { IsError : bool
      Message : string
      Timestamp : DateTimeOffset }

/// A process result including error code, message log and errors.
type ProcessResult =
    { ExitCode : int<commit_msg>Allow to set process encoding - fixes #1215<commit_after>﻿[<AutoOpen>]
/// Contains functions which can be used to start other tools.
module Fake.ProcessHelper

open System
open System.ComponentModel
open System.Diagnostics
open System.IO
open System.Threading
open System.Text
open System.Collections.Generic
open System.Collections.Concurrent
open System.ServiceProcess


/// If set to true the ProcessHelper will start all processes with a custom ProcessEncoding.
/// If set to false (default) only mono processes will be changed.
let mutable AlwaysSetProcessEncoding = false

/// The ProcessHelper will start all processes with this encoding if AlwaysSetProcessEncoding is set to true.
/// If AlwaysSetProcessEncoding is set to false (default) only mono processes will be changed.
let mutable ProcessEncoding = Encoding.UTF8

/// [omit]
type internal ConcurrentBag<'T> with
    member internal this.Clear() =
        while not(this.IsEmpty) do
            this.TryTake() |> ignore

/// [omit]
let startedProcesses = ConcurrentBag()

/// [omit]
let start (proc : Process) =
    if isMono || AlwaysSetProcessEncoding then
        try
            System.Console.OutputEncoding <- ProcessEncoding
        with exn ->
            logfn "Failed setting console encoding, ignoring error... %s." exn.Message

    if isMono && proc.StartInfo.FileName.ToLowerInvariant().EndsWith(".exe") then
        proc.StartInfo.Arguments <- "--debug \"" + proc.StartInfo.FileName + "\" " + proc.StartInfo.Arguments
        proc.StartInfo.FileName <- monoPath

    proc.Start() |> ignore
    startedProcesses.Add(proc.Id, proc.StartTime) |> ignore

/// [omit]
let mutable redirectOutputToTrace = false

/// [omit]
let mutable enableProcessTracing = true

/// A record type which captures console messages
type ConsoleMessage =
    { IsError : bool
      Message : string
      Timestamp : DateTimeOffset }

/// A process result including error code, message log and errors.
type ProcessResult =
    { ExitCode : int
{'fraction_non_alphanumeric': 0.09125283589614318, 'fraction_numerical': 0.0017645576002016637, 'mean_word_length': 3.3893805309734515, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6253251', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1031, 'n_words': 378}