-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable import-module to be case insensitive #5097
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 all commits
247b0db
6077272
fac1155
b4f7c01
fd7dcfb
169e597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ using System.Management.Automation; // Windows PowerShell namespace. | |
|
|
||
| namespace ModuleCmdlets | ||
| { | ||
| [Cmdlet(VerbsDiagnostic.Test,"BinaryModuleCmdlet1")] | ||
| [Cmdlet(VerbsDiagnostic.Test,"BinaryModuleCmdlet1")] | ||
| public class TestBinaryModuleCmdlet1Command : Cmdlet | ||
| { | ||
| protected override void BeginProcessing() | ||
|
|
@@ -124,3 +124,41 @@ namespace ModuleCmdlets | |
| } | ||
| } | ||
|
|
||
| Describe "Import-Module should be case insensitive" -Tags 'CI' { | ||
| BeforeAll { | ||
| $defaultPSModuleAutoloadingPreference = $PSModuleAutoloadingPreference | ||
| $originalPSModulePath = $env:PSModulePath.Clone() | ||
| $modulesPath = "$TestDrive\Modules" | ||
| $env:PSModulePath += [System.IO.Path]::PathSeparator + $modulesPath | ||
| $PSModuleAutoloadingPreference = "none" | ||
| } | ||
|
|
||
| AfterAll { | ||
| $global:PSModuleAutoloadingPreference = $defaultPSModuleAutoloadingPreference | ||
| $env:PSModulePath = $originalPSModulePath | ||
| } | ||
|
|
||
| AfterEach { | ||
| Remove-Item -Recurse -Path $modulesPath -Force -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| It "Import-Module can import a module using different casing using '<modulePath>' and manifest:<manifest>" -TestCases @( | ||
| @{modulePath="TESTMODULE/1.1"; manifest=$true}, | ||
| @{modulePath="TESTMODULE" ; manifest=$true}, | ||
| @{modulePath="TESTMODULE" ; manifest=$false} | ||
| ) { | ||
| param ($modulePath, $manifest) | ||
| New-Item -ItemType Directory -Path "$modulesPath/$modulePath" -Force > $null | ||
| if ($manifest) { | ||
| New-ModuleManifest -Path "$modulesPath/$modulePath/TESTMODULE.psd1" -RootModule "TESTMODULE.psm1" -ModuleVersion 1.1 | ||
| } | ||
| Set-Content -Path "$modulesPath/$modulePath/TESTMODULE.psm1" -Value "function mytest { 'hello' }" | ||
| Import-Module testMODULE | ||
|
||
| $m = Get-Module TESTmodule | ||
| $m | Should BeOfType "System.Management.Automation.PSModuleInfo" | ||
| $m.Name | Should Be "TESTMODULE" | ||
| mytest | Should BeExactly "hello" | ||
| Remove-Module TestModule | ||
| Get-Module tESTmODULE | Should BeNullOrEmpty | ||
| } | ||
| } | ||
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.
Please use Utils.NativeEnumerateDirectory()
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/Utils.cs#L926
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.
Will change
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.
This method appears to be only implemented for Win32. Since this path is only for UNIX, I'll leave it as-is.
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.
ok