Skip to content

Conversation

o-l-a-v
Copy link
Contributor

@o-l-a-v o-l-a-v commented Sep 21, 2025

PR Summary

Don't throw if no subdirectories are found.

This code is a bit confusing though, I don't get why it searches for version directories with no validation logic.

https://github.com/o-l-a-v/PowerShell--PSResourceGet/blob/3d28924d4d90b05911dc0f1a40bcff14e927dfc0/src/code/GetInstalledPSResource.cs#L101-L111

I won't try to rewrite that, as I'm sure it has a purpose. I'll just make the error non terminating.

PR Context

Closes #1815

PR Checklist

@o-l-a-v o-l-a-v changed the title Fix-Fix 1815 - Don't throw if no subdirectories were found Fix 1815 - Get-InstalledPSResource -Path don't throw if no subdirectories were found Sep 21, 2025
Copy link
Member

@alerickson alerickson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following test is currently failing:

Should not throw on ErrorAction ignore when no subdirectories are found 4ms
      ArgumentNullException: Scriptblock not found. Input to 'Throw' and 'Not Throw' must be enclosed in curly braces. (Parameter 'ActualValue')
      at Should-Throw, /home/vsts/work/_temp/TempModules/Pester/4.10.1/Functions/Assertions/PesterThrow.ps1: line 35
      at <ScriptBlock>, /home/vsts/work/1/s/test/GetInstalledPSResource/GetInstalledPSResource.Tests.ps1: line 157
 

@o-l-a-v
Copy link
Contributor Author

o-l-a-v commented Oct 1, 2025

Oops, I enclosed the test in scriptblock now @alerickson. 😊

@alerickson alerickson enabled auto-merge (squash) October 2, 2025 21:56
@alerickson alerickson merged commit cfb6180 into PowerShell:master Oct 2, 2025
4 checks passed
@alerickson
Copy link
Member

Thanks @o-l-a-v!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-InstalledPSResource -ErrorAction Ignore -Path throws if path contains no directories

3 participants