Skip to content

Commit

Permalink
Merge pull request #6 from andrewrdavidson/release-1.0.5
Browse files Browse the repository at this point in the history
Fixes for module manifests not existing
  • Loading branch information
andrewrdavidson authored Dec 21, 2020
2 parents 543e198 + 102e26c commit de123a6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion PSQualityCheck.Functions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'PSQualityCheck.Functions.psm1'

# Version number of this module.
ModuleVersion = '1.0.4'
ModuleVersion = '1.0.5'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
65 changes: 47 additions & 18 deletions PSQualityCheck.Functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -399,46 +399,75 @@ function Get-FunctionCount {
[string]$ManifestFile
)

try {
if (Test-Path -Path $ManifestFile) {
$ExportedCommands = @((Test-ModuleManifest -Path $ManifestFile).ExportedCommands)
$ExportedCommandsCount = $ExportedCommands.Count
}
else {
throw "Manifest file doesn't exist"
}
}
catch {
$ExportedCommands = @()
$ExportedCommandsCount = 0
}
try {
if (Test-Path -Path $ModuleFile) {
($ParsedModule, $ParserErrors) = Get-ParsedFile -Path $ModuleFile
}
else {
throw "Module file doesn't exist"
}
}
catch {
$ParsedModule = @()
$ParserErrors = 1
}

$CommandFoundInModuleCount = 0
$CommandFoundInManifestCount = 0
$CommandInModule = 0
$CommandInModuleCount = 0

$ExportedCommands = (Test-ModuleManifest -Path $ManifestFile).ExportedCommands
if ( -not ([string]::IsNullOrEmpty($ParsedModule))) {

($ParsedModule, $ParserErrors) = Get-ParsedFile -Path $ModuleFile
foreach ($ExportedCommand in $ExportedCommands.Keys) {

foreach ($ExportedCommand in $ExportedCommands.Keys) {
if ( ($ParsedModule | Where-Object { $_.Type -eq "CommandArgument" -and $_.Content -eq $ExportedCommand })) {

if ( ($ParsedModule | Where-Object { $_.Type -eq "CommandArgument" -and $_.Content -eq $ExportedCommand })) {
$CommandFoundInModuleCount++

$CommandFoundInModuleCount++
}

}

}
$functionNames = @()

$functionNames = @()
$functionKeywords = ($ParsedModule | Where-Object { $_.Type -eq "Keyword" -and $_.Content -eq "function" })
$functionKeywords | ForEach-Object {

$functionKeywords = ($ParsedModule | Where-Object { $_.Type -eq "Keyword" -and $_.Content -eq "function" })
$functionKeywords | ForEach-Object {

$functionLineNo = $_.StartLine
$functionNames += ($ParsedModule | Where-Object { $_.Type -eq "CommandArgument" -and $_.StartLine -eq $functionLineNo })
$functionLineNo = $_.StartLine
$functionNames += ($ParsedModule | Where-Object { $_.Type -eq "CommandArgument" -and $_.StartLine -eq $functionLineNo })

}
}

$functionNames | ForEach-Object {
if ($ExportedCommandsCount -ge 1) {

$functionNames | ForEach-Object {

$CommandInModule++
if ($ExportedCommands.ContainsKey($_.Content)) {
$CommandInModuleCount++
if ($ExportedCommands.ContainsKey($_.Content)) {

$CommandFoundInManifestCount++
$CommandFoundInManifestCount++

}

}

}

return ($ExportedCommands.Count, $CommandFoundInModuleCount, $CommandInModule, $CommandFoundInManifestCount)
return ($ExportedCommandsCount, $CommandFoundInModuleCount, $CommandInModule, $CommandFoundInManifestCount)

}

Expand Down
2 changes: 1 addition & 1 deletion PSQualityCheck.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'PSQualityCheck.psm1'

# Version number of this module.
ModuleVersion = '1.0.4'
ModuleVersion = '1.0.5'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit de123a6

Please sign in to comment.