File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -56,4 +56,4 @@ if ($ModuleMetadata.RootModule) {
56
56
Add-PSM1Dependency - Path $moduleSourcePath
57
57
}
58
58
59
- Remove-ModuleDependencies - Path $moduleSourcePath
59
+ Remove-ModuleDependencies - Path $moduleSourcePath - KeepRequiredModules
Original file line number Diff line number Diff line change @@ -309,18 +309,26 @@ function Get-AllModules {
309
309
. PARAMETER Path
310
310
Path to the psd1 file.
311
311
312
+ . PARAMETER KeepRequiredModules
313
+ Switch to keep RequiredModules.
314
+
312
315
#>
313
316
function Remove-ModuleDependencies {
314
317
[CmdletBinding ()]
315
318
param (
316
- [string ]$Path
319
+ [string ]$Path ,
320
+
321
+ [Parameter (Mandatory = $false )]
322
+ [switch ]$KeepRequiredModules
317
323
)
318
324
319
325
PROCESS {
320
- $regex = New-Object System.Text.RegularExpressions.Regex " RequiredModules\s*=\s*@\([^\)]+\)"
321
- $content = (Get-Content - Path $Path ) -join " `r`n "
322
- $text = $regex.Replace ($content , " RequiredModules = @()" )
323
- Out-FileNoBom - File $Path - Text $text
326
+ if (-not $KeepRequiredModules.IsPresent ){
327
+ $regex = New-Object System.Text.RegularExpressions.Regex " RequiredModules\s*=\s*@\([^\)]+\)"
328
+ $content = (Get-Content - Path $Path ) -join " `r`n "
329
+ $text = $regex.Replace ($content , " RequiredModules = @()" )
330
+ Out-FileNoBom - File $Path - Text $text
331
+ }
324
332
325
333
$regex = New-Object System.Text.RegularExpressions.Regex " NestedModules\s*=\s*@\([^\)]+\)"
326
334
$content = (Get-Content - Path $Path ) -join " `r`n "
You can’t perform that action at this time.
0 commit comments