Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in New-HelpCabinetFile from OPS13 #705

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Microsoft.PowerShell.PlatyPS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ function MakeHelpInfoXml {
[xml] $HelpInfoContent = $xml
}

$null = $HelpInfoContent.Save($outputFullPath)
$outputItem = Get-Item $outputFullPath
$null = $HelpInfoContent.Save($outputItem.FullName)
# return this to the caller
$outputItem
}
Expand All @@ -260,7 +260,7 @@ function New-HelpCabinetFile {
param(
[parameter(Mandatory=$true)]
[ValidateScript({(Test-Path $_ -PathType Container)})]
[string] $CabinetFilesFolder,
[string] $HelpFilesFolder,

[parameter(Mandatory=$true)]
[ValidateScript({(Test-Path $_ -PathType Leaf)})]
Expand Down Expand Up @@ -307,22 +307,22 @@ function New-HelpCabinetFile {

Assert-Command MakeCab.exe
#Testing for files in source directory
if((Get-ChildItem -Path $CabinetFilesFolder).Count -le 0) {
throw "Path '${CabinetFilesFolder}' does not contain any files."
if((Get-ChildItem -Path $HelpFilesFolder).Count -le 0) {
throw "Path '${HelpFilesFolder}' does not contain any files."
}

#Testing for valid help file types
$ValidHelpFileTypes = '.xml', '.txt'
$HelpFiles = Get-ChildItem -Path $CabinetFilesFolder -File
$HelpFiles = Get-ChildItem -Path $HelpFilesFolder -File
$ValidHelpFiles = $HelpFiles | Where-Object { $_.Extension -in $ValidHelpFileTypes }
$InvalidHelpFiles = $HelpFiles | Where-Object { $_.Extension -notin $ValidHelpFileTypes }
if(-not $ValidHelpFiles) {
throw "No valid help files found in '${CabinetFilesFolder}'."
throw "No valid help files found in '${HelpFilesFolder}'."
}

if($InvalidHelpFiles) {
$InvalidHelpFiles | ForEach-Object {
Write-Warning -Message "File '${$_}' is not a valid help file type. Excluding from Cab file."
Write-Warning -Message "File '$_' is not a valid help file type. Excluding from Cab file."
}
}

Expand Down Expand Up @@ -393,7 +393,7 @@ function New-HelpCabinetFile {
}
}
}

$outputFiles
}
}
Loading