Internal/Confirm-IsInitializedModulePath.ps1
function Confirm-IsInitializedModulePath { <# .Synopsis Confirm-IsInitializedModulePath does this... Short description .DESCRIPTION Confirm-IsInitializedModulePath does this, that, and the other... Long description .EXAMPLE Confirm-IsInitializedModulePath "DEV" .\Here\this\path\file.txt #> [CmdletBinding(SupportsShouldProcess=$true)] param () BEGIN{ Write-Verbose "Starting Confirm-IsInitializedModulePath..." $moduleFolders = @( "Public", "Internal" ) }#begin PROCESS{ if ($psCmdlet.ShouldProcess(<# on target --> #>"Current Path", <# What if: Performing operation --> #>"Checking for module files & folders")) { Write-Verbose "Checking for module files & folders" if (-not (Test-Path -Path $moduleFolders -PathType Container)) { throw "No module folders $($moduleFolders -join ', '). This is not an initialized PSM module path, please navigate to the root of the module directory." } if(-not (Test-Path -Path "module-psd1.xml" -PathType Leaf)) { throw "No module-psd1.xml file. This is not an initialized PSM module path, please navigate to the root of the module directory." } $packageXml = Import-CliXml .\module-psd1.xml if(-not (Test-Path -Path @("$($packageXml.ModuleName).psd1", "$($packageXml.ModuleName).psm1") -PathType Leaf)) { throw "No .psd1 or .psm1 file(s). This is not an initialized PSM module path, please navigate to the root of the module directory." } Write-Verbose "This is an initialized PSM module path!" } }#process END{ Write-Verbose "Finished Confirm-IsInitializedModulePath..." }#end } |