File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,12 +36,13 @@ function New-CommandDataFile {
3636 [OutputType ([System.IO.FileInfo ])]
3737 [CmdletBinding ()]
3838 param (
39+ [ValidateScript ({ Test-Path $_ })]
3940 [string ]$OutputPath = ' ./' # Default is current directory
4041 )
4142
4243 $builtinModulePath = Microsoft.PowerShell.Management\Join-Path $PSHOME ' Modules'
4344 if (-not (Microsoft.PowerShell.Management\Test-Path $builtinModulePath )) {
44- throw new " $builtinModulePath does not exist! Cannot create command data file."
45+ throw " $builtinModulePath does not exist! Cannot create command data file."
4546 }
4647
4748 # # Get the PowerShell edition, OS, and platform to create a unique file name for the JSON file
@@ -76,6 +77,10 @@ function New-CommandDataFile {
7677 foreach ($module in $modules ) {
7778 Microsoft.PowerShell.Utility\Write-Verbose " Processing module $module "
7879 $commands = Microsoft.PowerShell.Core\Get-Command - Module $module
80+ if (-not $commands ) {
81+ Microsoft.PowerShell.Utility\Write-Error " No commands found for module '$module '; skipping."
82+ continue
83+ }
7984 $shortCommands = $commands |
8085 Microsoft.PowerShell.Utility\Select-Object - Property Name,
8186 @ {Label = ' CommandType' ; Expression = { $_.CommandType.ToString () } },
You can’t perform that action at this time.
0 commit comments