Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow module without version #600

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Gijsreyn
Copy link
Contributor

PR Summary

Allow modules that don't have a version directory to be added in $env:PSModulePath.

PR Context

The Get-DscResourceModules function scans the $env:PSModulePath to find relevant modules to be included in the cache. When a module doesn't have a version directory, it does not find the module. This change allows the ability to include modules that don't contain the directory.

I added this change because it can be useful for testing purposes to see the participation of DSC resources when developing them. For example, take the winget-dsc repository. Simply adding the resource to the environment variable adds it for participation.

@Gijsreyn
Copy link
Contributor Author

@SteveL-MSFT I know you have a ton on your plate, but hopefully you have some time to check out this small change. If you want me to add a test, I can make a duplicate of the TestClassResource. Thanks.

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

Please add a test

@Gijsreyn
Copy link
Contributor Author

Tests have been included. If you need it in the config, let me know, thought I don't believe it is needed.

$containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*'
if($null -ne $containsDSCResource)
{
$moduleFolders = Get-ChildItem $folder -Directory
Copy link
Member

Choose a reason for hiding this comment

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

What's not clear to me is why the original code didn't just use Get-Module -ListAvailable instead of parsing PSModulePath and replicating some of that logic. @anmenaga ?

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.

2 participants