microsoft / microsoft/winget-cli-restsource
The Test-PowerShellModuleExist function is irrelevant and should be removed
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 317
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
Brief description of your issue
PowerShell provides a native way to check for required modules and a separate function isn't needed as documented here:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-7.4#-modules-module-name--hashtable
The entire test logic for the modules can be replaced by the single line:
#Requires -Modules Az.Resources, Az.Accounts, Az.Websites, Az.Functions, Az.Storage
This line can be placed anywhere in the script, but goes into the begin block by convention.
I will improve the script be bringing it inline with PowerShell standards and making it quicker to error when the modules are not present.
Steps to reproduce
Remove the module test logic and replace with the single line above
Expected behavior
the module cannot be loaded without the modules being present
Actual behavior
module loads, but fails on initial run.
Environment
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the PowerShell script containing Test-PowerShellModuleExist and read its module-loading and begin-block logic. Replace the existing module test as described in the issue, then verify that the script fails immediately when the required modules are unavailable and loads when they are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100