Fix restore of dependency chain for publish (#89)

* Fix restore of dependency chain for publish

* Add dev switch
This commit is contained in:
Bernie White 2022-08-14 16:24:49 +10:00 коммит произвёл GitHub
Родитель df2458b433
Коммит f506aa7926
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

@ -291,7 +291,7 @@ task ScaffoldHelp Build, {
task Dependencies NuGet, {
Import-Module $PWD/scripts/dependencies.psm1;
Install-Dependencies -Path $PWD/modules.json;
Install-Dependencies -Path $PWD/modules.json -Dev;
}
# Synopsis: Remove temp files.

Просмотреть файл

@ -7,8 +7,8 @@
function Update-Dependencies {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[String]$Path,
[Parameter(Mandatory = $False)]
[String]$Path = (Join-Path -Path $PWD -ChildPath 'modules.json'),
[Parameter(Mandatory = $False)]
[String]$Repository = 'PSGallery'
@ -45,18 +45,23 @@ function Update-Dependencies {
function Install-Dependencies {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[String]$Path,
[Parameter(Mandatory = $False)]
[String]$Path = (Join-Path -Path $PWD -ChildPath 'modules.json'),
[Parameter(Mandatory = $False)]
[String]$Repository = 'PSGallery'
[String]$Repository = 'PSGallery',
[Parameter(Mandatory = $False)]
[Switch]$Dev
)
process {
$modules = Get-Content -Path $Path -Raw | ConvertFrom-Json;
InstallVersion $modules.dependencies -Repository $Repository;
if ($Dev) {
InstallVersion $modules.devDependencies -Repository $Repository -Dev;
}
}
}
function CheckVersion {
[CmdletBinding()]
@ -133,7 +138,7 @@ function InstallVersion {
process {
foreach ($module in $InputObject.PSObject.Properties.GetEnumerator()) {
Write-Host -Object "[$group] -- Installing $($module.Name) v$($module.Value.version)";
$installParams = @{ MinimumVersion = $module.Value.version };
$installParams = @{ RequiredVersion = $module.Value.version };
if ($Null -eq (Get-InstalledModule -Name $module.Name @installParams -ErrorAction Ignore)) {
Install-Module -Name $module.Name @installParams -Force -Repository $Repository;
}