mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Revert "Allow empty prefix string in 'Import-Module -Prefix' to override default prefix in manifest (#20409)" (#25462)
This commit is contained in:
@@ -1620,7 +1620,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (bailOnFirstError) return null;
|
||||
}
|
||||
|
||||
string resolvedCommandPrefix = BasePrefix ?? defaultCommandPrefix ?? string.Empty;
|
||||
string resolvedCommandPrefix = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(defaultCommandPrefix))
|
||||
{
|
||||
resolvedCommandPrefix = defaultCommandPrefix;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(this.BasePrefix))
|
||||
{
|
||||
resolvedCommandPrefix = this.BasePrefix;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(actualRootModule))
|
||||
{
|
||||
|
||||
@@ -57,18 +57,6 @@ Describe "Import-Module" -Tags "CI" {
|
||||
(Get-Module TestModule).Version | Should -BeIn "1.1"
|
||||
}
|
||||
|
||||
|
||||
It 'Should override default command prefix if an empty string is provided' {
|
||||
$ModuleName = "PrefixTestModule"
|
||||
$ModulePath = Join-Path -Path $testdrive -ChildPath $ModuleName
|
||||
$null = New-Item -Path $ModulePath -ItemType Directory -Force
|
||||
'function Use-Something{}' | Set-Content -Path "$ModulePath\$ModuleName.psm1" -Force
|
||||
New-ModuleManifest -Path "$ModulePath\$ModuleName.psd1" -DefaultCommandPrefix MyPrefix -FunctionsToExport Use-Something -RootModule "$ModuleName.psm1"
|
||||
$ImportedModule = Import-Module -Name "$ModulePath\$ModuleName.psd1" -Prefix "" -PassThru
|
||||
$ImportedModule.ExportedCommands.ContainsKey('Use-Something') | Should -Be $true
|
||||
Remove-Module -ModuleInfo $ImportedModule
|
||||
}
|
||||
|
||||
It 'ProcessorArchitecture should work' {
|
||||
$currentProcessorArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture) {
|
||||
'X86' { 'x86' }
|
||||
|
||||
Reference in New Issue
Block a user