Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 6 additions & 56 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -663,21 +663,19 @@ function Restore-PSModuleToBuild
if($CI.IsPresent)
{
# take the latest version of pester and install it so it may be used
Save-Module -Path $modulesDir -Name Pester
Restore-PSPester -Destination $modulesDir
}
}

function Restore-PSPester
{
param
(
param(
[ValidateNotNullOrEmpty()]
[string]
$Destination = ([IO.Path]::Combine((Split-Path (Get-PSOptions -DefaultToNew).Output), "Modules"))
[string] $Destination = ([IO.Path]::Combine((Split-Path (Get-PSOptions -DefaultToNew).Output), "Modules"))
)

Restore-GitModule -Destination $Destination -Uri 'https://github.com/PowerShell/psl-pester' -Name Pester -CommitSha '1f546b6aaa0893e215e940a14f57c96f56f7eff1'
Save-Module -Name Pester -Path $Destination -Repository PSGallery
}

function Compress-TestContent {
[CmdletBinding()]
param(
Expand Down Expand Up @@ -988,7 +986,7 @@ function Start-PSPester {
Write-Warning @"
Pester module not found.
Restore the module to '$Pester' by running:
Save-Module Pester -Path '$binDir/Modules'
Restore-PSPester
"@
return;
}
Expand Down Expand Up @@ -2436,54 +2434,6 @@ function Clear-PSRepo
}
}


# Install PowerShell modules from a git Repo such as PSL-Pester
function Restore-GitModule
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Name,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Uri,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Destination,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$CommitSha
)

log 'Restoring module from git repo:'
log ("Name='{0}', Destination='{1}', Uri='{2}', CommitSha='{3}'" -f $Name, $Destination, $Uri, $CommitSha)

$clonePath = Join-Path -Path $Destination -ChildPath $Name
if(Test-Path $clonePath)
{
remove-Item -Path $clonePath -recurse -force
}

$null = Start-NativeExecution {git clone --quiet $uri $clonePath}

Push-location $clonePath
try {
$null = Start-NativeExecution {git checkout --quiet -b desiredCommit $CommitSha} -SuppressOutput

$gitItems = Join-Path -Path $clonePath -ChildPath '.git*'
$ymlItems = Join-Path -Path $clonePath -ChildPath '*.yml'
Get-ChildItem -attributes hidden,normal -Path $gitItems, $ymlItems | Remove-Item -Recurse -Force
}
finally
{
pop-location
}
}

# Install PowerShell modules such as PackageManagement, PowerShellGet
function Restore-PSModule
{
Expand Down