Skip to content

Commit

Permalink
Fix restore of dependency chain for publish (#89)
Browse files Browse the repository at this point in the history
* Fix restore of dependency chain for publish

* Add dev switch
  • Loading branch information
BernieWhite authored Aug 14, 2022
1 parent df2458b commit f506aa7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pipeline.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 13 additions & 8 deletions scripts/dependencies.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,7 +19,7 @@ function Update-Dependencies {
$devDependencies = CheckVersion $modules.devDependencies -Repository $Repository -Dev;

$modules = [Ordered]@{
dependencies = $dependencies
dependencies = $dependencies
devDependencies = $devDependencies
}
$modules | ConvertTo-Json -Depth 10 | Set-Content -Path $Path;
Expand All @@ -45,16 +45,21 @@ 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;
InstallVersion $modules.devDependencies -Repository $Repository -Dev;
if ($Dev) {
InstallVersion $modules.devDependencies -Repository $Repository -Dev;
}
}
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f506aa7

Please sign in to comment.