Skip to content

Commit 748bbff

Browse files
committed
Copilot feedback
1 parent dcc15df commit 748bbff

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Utils/New-CommandDataFile.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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() } },

0 commit comments

Comments
 (0)