function Set-EOL { <# .SYNOPSIS Helper function to set the EOL sequence to LF or CRLF. .DESCRIPTION Helper for changing the EOL independent to the current OS defaults. .PARAMETER Style Optional style parameter for `unix` or `win.`. Default is `unix`. .PARAMETER Path Mandatory path for target file. .INPUTS [None] No pipeline input. .OUTPUTS [DroneHelper.Repo.Path] Returns a folder structured like object with relevant full paths.s .EXAMPLE Import-Module -Name DroneHelper; Set-EOL -Path './Readme.md' #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseShouldProcessForStateChangingFunctions', '', Justification = 'system state does not change permanent in temp build clients.' )] param ( [Parameter(Mandatory = $false)] [ValidateSet('unix', 'win')] [String]$Style = 'unix', [Parameter(Mandatory = $true)] [System.IO.FileInfo]$Path ) process { if (!(Test-Path $Path.FullName)) { Write-Error -Message ('{0} not found!' -f $Path.FullName) -ErrorAction Stop } switch ($Style) { 'unix' { $eol = "`n" Write-Verbose -Message ('Reading {0}' -f $Path.FullName) $text = [IO.File]::ReadAllText($Path.FullName) -replace "`r`n", $eol Write-Debug -Message $text } 'win' { $eol = "`r`n" $text = [IO.File]::ReadAllText($Path.FullName) -replace "`n", $eol } } Write-Verbose -Message ("Writing back {0}" -f $Path.FullName) [IO.File]::WriteAllText($Path.FullName, $text) } }