Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit a500086

Browse files
committed
Allow Update-ModuleManifest to take an empty array of functions or commandlets to export
1 parent 58e8fc6 commit a500086

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

Tests/PSGetUpdateModuleManifest.Tests.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Describe PowerShell.PSGet.UpdateModuleManifest -Tags 'BVT','InnerLoop' {
152152
# Action:
153153
# Update-ModuleManifest -Path [Path]
154154
#
155-
# Expected Result: The updated manifest should have the same DefaultCommandPreifx as before,
155+
# Expected Result: The updated manifest should have the same DefaultCommandPrefix as before,
156156
# CmdletsToExport, FunctionsToExport, AliasesToExport, DSCResourcesToExport should not have prefixes affixed
157157
#
158158
It UpdateModuleManifestWithDefaultCommandPrefix {
@@ -197,6 +197,22 @@ Describe PowerShell.PSGet.UpdateModuleManifest -Tags 'BVT','InnerLoop' {
197197
}
198198
}
199199

200+
# Purpose: Update a module manifest with an empty array of commandlets and functions to export
201+
#
202+
# Action: Update-ModuleManifest -Path [path] -CmdletsToExport "" -functions ""
203+
#
204+
# Expected Result: The updated module manifest should have no commandlets or functions to export
205+
#
206+
It "UpdateModuleManifestWithEmptyFunctionsAndCmdletsToExport" {
207+
New-ModuleManifest -Path $script:testManifestPath -Confirm:$false -CmdletsToExport "commandlet1","commandlet2" `
208+
-FunctionsToExport "function1","function2" -AliasesToExport "alias1","alias2"
209+
Update-ModuleManifest -Path $script:testManifestPath -CmdletsToExport "" -FunctionsToExport "" -AliasesToExport ""
210+
$updatedModuleInfo = Test-ModuleManifest -Path $script:testManifestPath
211+
212+
AssertEquals $updatedModuleInfo.FunctionsToExport.Count 0 "FunctionsToExport count should be 0"
213+
AssertEquals $updatedModuleInfo.CmdletsToExport.Count 0 "CmdletsToExport count should be 0"
214+
AssertEquals $updatedModuleInfo.AliasesToExport.Count 0 "AliasesToExport count should be 0"
215+
}
200216

201217

202218
# Purpose: Update a module manifest with same parameters

src/PowerShellGet/public/psgetfunctions/Update-ModuleManifest.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ function Update-ModuleManifest
124124
$ModuleList,
125125

126126
[Parameter()]
127-
[ValidateNotNullOrEmpty()]
128127
[string[]]
129128
$FunctionsToExport,
130129

131130
[Parameter()]
132-
[ValidateNotNullOrEmpty()]
133131
[string[]]
134132
$AliasesToExport,
135133

@@ -139,7 +137,6 @@ function Update-ModuleManifest
139137
$VariablesToExport,
140138

141139
[Parameter()]
142-
[ValidateNotNullOrEmpty()]
143140
[string[]]
144141
$CmdletsToExport,
145142

@@ -497,7 +494,7 @@ function Update-ModuleManifest
497494
$params.Add("ModuleList",$ModuleManifestHashtable.ModuleList)
498495
}
499496

500-
if($FunctionsToExport)
497+
if($FunctionsToExport -or $FunctionsToExport -is [array])
501498
{
502499
$params.Add("FunctionsToExport",$FunctionsToExport)
503500
}
@@ -523,7 +520,7 @@ function Update-ModuleManifest
523520
}
524521
}
525522

526-
if($AliasesToExport)
523+
if($AliasesToExport -or $AliasesToExport -is [array])
527524
{
528525
$params.Add("AliasesToExport",$AliasesToExport)
529526
}
@@ -568,7 +565,7 @@ function Update-ModuleManifest
568565
}
569566
}
570567

571-
if($CmdletsToExport)
568+
if($CmdletsToExport -or $CmdletsToExport -is [array])
572569
{
573570
$params.Add("CmdletsToExport", $CmdletsToExport)
574571
}

0 commit comments

Comments
 (0)