Public/Add-PsmInternalFunction.ps1

function Add-PsmInternalFunction {
  <#
    .Synopsis
      A function that creates an internal function.ps1 and function.Tests.ps1 file stub
    .DESCRIPTION
      A function that creates an internal function.ps1 and function.Tests.ps1 file stub for
      an easy start to creating powershell modules/function in a TDD manner
    .EXAMPLE
      Add-PsmInternalFunction "Write-HereWeGo"
      Add-PsmInternalFunction "Write-HereWeGo" -Whatif
  #>

  [CmdletBinding(SupportsShouldProcess=$true)]
  param(
    [Parameter(
        Mandatory=$true, 
        ValueFromPipeline=$true,
        ValueFromPipelineByPropertyName=$true)]
    [ValidatePattern("^[a-zA-Z]{3,}-[a-zA-Z]{3,}$")]
    [string]$functionName
  )
  
  BEGIN{
    Write-Verbose "Starting Add-PsmInternalFunction..."
    Confirm-IsInitializedModulePath
    $packageXml = Import-CliXml .\module-psd1.xml
  }#begin

  PROCESS{
    if ($psCmdlet.ShouldProcess(<# on target --> #>"$($packageXml.RootModule)", <# What if: Performing operation --> #>"Adding new internal function $functionName")) {    
      
      Show-IsApprovedVerb $functionName

      if (Test-Path -Path .\Internal -PathType Container) {
        Get-PsmFunctionContent $functionName | Set-Content .\Internal\$functionName.ps1

        Write-Host ".\Internal\$functionName.ps1 file written"
      } else {
        Write-Error "No .\Internal folder found, this is not an initialized module folder... Run: ``Initialize-Psm``"
      }
    }
  }#process

  END{
    Write-Verbose "Finished Add-PsmInternalFunction..."
  }#end
}