OCram85/DroneHelper
OCram85
/
DroneHelper
Archived
1
0
Fork 0
This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
DroneHelper/src/FileLinter/Test-FileTab.ps1

57 lines
1.1 KiB
PowerShell

function Test-FileTab {
<#
.SYNOPSIS
Returns false if tab char is used in file.
.DESCRIPTION
Test the given file if tabs are used. Returns false if any tabs were found.
.PARAMETER Path
elative or full path to an existing file.
.INPUTS
[none]
.OUTPUTS
[bool]
.EXAMPLE
Test-FileTab -Path './testfile.txt'
.NOTES
#>
[CmdletBinding()]
[OutputType([bool])]
param (
[Parameter(Mandatory = $true)]
[ValidateScript(
{
Test-Path -Path $_
}
)]
[string]$Path
)
begin {
}
process {
$content = Get-Content -Path $Path -Raw -Encoding 'utf8'
$Tabs = ([regex]::Matches($content, "`t")).Count
if ($Tabs -ne 0 ) {
Write-Debug -Message ('Tabs: {0} -> false' -f $Tabs)
Write-Output $false
}
else {
Write-Debug -Message ('Tabs: {0} -> true' -f $Tabs)
Write-Output $true
}
}
end {
}
}