Skip to content

Instantly share code, notes, and snippets.

@The-Running-Dev
Last active April 21, 2017 12:47
Show Gist options
  • Save The-Running-Dev/c5acdfb412ba24c75937f5197bec452f to your computer and use it in GitHub Desktop.
Save The-Running-Dev/c5acdfb412ba24c75937f5197bec452f to your computer and use it in GitHub Desktop.
Test Chocolatey Package Installation
function Test-Install {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Position = 0, Mandatory = $true)] [string] $package,
[Parameter(Position = 1, Mandatory = $false)] [string] $baseDir = (Get-Location)
)
$profilePath = Split-Path -Parent $profile
$packageExtensions = (Join-Path $profilePath '..\..\Projects\BoxStarter\Chocolatey-Package.extension\extensions\Chocolatey-Package.extension.psm1' -Resolve)
Clear-Host
$packagesRoot = (Join-Path $baseDir .. -Resolve)
$package = $package -replace '\.|\\', ''
$packageFound = (Get-ChildItem $packagesRoot "$package.nuspec" -Recurse)
$found = @{ $true = $packageFound.FullName; $false = 'Nothing'}[$packageFound -ne $null]
Write-Host "Base Directory: $baseDir"
Write-Host "Package: $package. Found: $found."
if ($packageFound) {
$packageDir = Split-Path -Parent $packageFound.FullName
Write-Host "Package Directory: $packageDir"
$env:ChocoDebug = $true
$env:ChocolateyPackageName = $package
$env:ChocolateyPackageTitle = $package
$env:ChocolateyPackageFolder = $packageDir
$installScript = Join-Path $env:ChocolateyPackageFolder 'tools\ChocolateyInstall.ps1'
if($PSCmdlet.ShouldProcess("$installScript")){
Import-Module $packageExtensions -Force
& $installScript
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment