-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Support importing module paths that end in trailing directory separator #6602
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,12 @@ Describe "Import-Module" -Tags "CI" { | |
(Get-Module -Name $moduleName).Name | Should -BeExactly $moduleName | ||
} | ||
|
||
It "should be able to load a module with a trailing directory separator" { | ||
$modulePath = (Get-Module -ListAvailable $moduleName).ModuleBase + [System.IO.Path]::DirectorySeparatorChar | ||
Import-Module -Name $modulePath | ||
(Get-Module -Name $moduleName).Name | Should -BeExactly $moduleName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The module already was loaded in previous test. { Import-Module -Name $modulePath -ErrorAction Stop } | Should -Not -Throw
`` There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And maybe add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a |
||
} | ||
|
||
It "should be able to add a module with using ModuleInfo switch" { | ||
$a = Get-Module -ListAvailable $moduleName | ||
{ Import-Module -ModuleInfo $a } | Should -Not -Throw | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the code in the file, I get a feeling that it is better to place this new change (that removes trailing separator) before the call to
LoadUsingMultiVersionModuleBase
that is earlier in the file:foundModule = LoadUsingMultiVersionModuleBase(rootedPath,
This way version selection in the multi-version case will still work even with trailing separator in module path.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'll move it up and add a test.