1
0
mirror of https://github.com/jaapbrasser/SharedScripts.git synced 2025-12-24 21:51:38 +02:00

Added ExcludeFile parameter

This commit is contained in:
Jaap Brasser
2019-10-26 09:51:11 +09:00
parent 3ff96e6b77
commit fc427b8f94

View File

@@ -22,7 +22,9 @@ This function looks at a file structure and creates a tree representation in mar
# Included file types, specified by extension
[string[]] $IncludeExtensions = @('.md','pdf'),
# Whether to use clip.exe or to output to console
[switch] $NoClipBoard
[switch] $NoClipBoard,
# File exclusion list
[string[]] $ExcludeFile = @('license')
)
begin {
@@ -40,13 +42,21 @@ This function looks at a file structure and creates a tree representation in mar
$BuildMarkDown = {
Get-ChildItem -LiteralPath $Path | ForEach-Object {
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
"* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
if ($_.PSIsContainer) {
$_ | Get-ChildItem -Recurse | ? {$_.PSIsContainer -or $_.Extension -in $IncludeExtensions} | ForEach-Object {
$Count = ($_.FullName -split '\\').Count-($Path.Split('\').Count+1)
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
"$(" "*$Count*2)* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
if ((-not $_.PSIsContainer) -and ($ExcludeFile -contains $_.name)) {
# Do nothing
} else {
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
"* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
if ($_.PSIsContainer) {
$_ | Get-ChildItem -Recurse | ? {$_.PSIsContainer -or $_.Extension -in $IncludeExtensions} | ForEach-Object {
if ((-not $_.PSIsContainer) -and ($ExcludeFile -contains $_.name)) {
# Do nothing
} else {
$Count = ($_.FullName -split '\\').Count-($Path.Split('\').Count+1)
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
"$(" "*$Count*2)* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
}
}
}
}
}