Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-499) Do not throw if missing chocolateyUninstall.ps1
  (maint) formatting
  • Loading branch information
ferventcoder committed Jun 27, 2014
2 parents 2f6847a + 95db2bf commit 7942d92
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/functions/Run-ChocolateyPS1.ps1
@@ -1,27 +1,27 @@
function Run-ChocolateyPS1 {
param(
[string] $packageFolder,
[string] $packageName,
[string] $packageFolder,
[string] $packageName,
[string] $action,
[string] $installerArguments = ''
)
Write-Debug "Running 'Run-ChocolateyPS1' for $packageName with packageFolder:`'$packageFolder`', action: `'$action`'";

switch ($action)
switch ($action)
{
"install" { $actionFile = "chocolateyinstall.ps1"; }
"uninstall" {$actionFile = "chocolateyuninstall.ps1"; }
default { $actionFile = "chocolateyinstall.ps1";}
}

if ($packageFolder -notlike '') {
if ($packageFolder -notlike '') {

Write-Debug " __ PowerShell $action ($actionFile) __"
Write-Debug " Looking for $actionFile in folder `'$packageFolder`'. If $actionFile is found, it will be run."

$ps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match $actionFile} | sort name -Descending | select -First 1
$installps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match 'chocolateyinstall.ps1'} | sort name -Descending | select -First 1

Write-Debug "Action file is `'$ps1`'"

if ($ps1 -notlike '') {
Expand All @@ -30,19 +30,19 @@ param(
$env:chocolateyInstallOverride = $null
if ($overrideArgs -eq $true) {
$env:chocolateyInstallOverride = $true
}
}

$ps1FullPath = $ps1.FullName
Write-Debug "Running `'$ps1FullPath`'";
& "$ps1FullPath"
$env:chocolateyInstallArguments = ''
$env:chocolateyInstallOverride = $null

# $importChocolateyHelpers = "";
# Get-ChildItem "$nugetChocolateyPath\helpers" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "& import-module -name `'$($_.FullName)`';$importChocolateyHelpers" };
# Run-ChocolateyProcess powershell "-NoProfile -ExecutionPolicy unrestricted -Command `"$importChocolateyHelpers & `'$ps1FullPath`'`"" -elevated
##testing Start-Process -FilePath "powershell.exe" -ArgumentList " -noexit `"$ps1FullPath`"" -Verb "runas" -Wait #-PassThru -UseNewEnvironment ##-RedirectStandardError $errorLog -WindowStyle Normal

#detect errors
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
Expand All @@ -60,7 +60,7 @@ param(
}

if ($installps1 -notlike '' -and $ps1 -like '') {
throw "This package has a chocolateyInstall.ps1 without a chocolateyUninstall.ps1. You will need to manually reverse whatever steps the installer did. Please ask the package maker to include a chocolateyUninstall.ps1 in the file to really remove the package."
Write-Host "This package has a chocolateyInstall.ps1 without a chocolateyUninstall.ps1. You will need to manually reverse whatever steps the installer did. Please ask the package maker to include a chocolateyUninstall.ps1 in the file to really remove the package." -ForegroundColor $Warning -BackgroundColor Black
}
}
}

0 comments on commit 7942d92

Please sign in to comment.