From 35f9a0491d61d4af5727285e17a0b1601ef96f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Sun, 29 Jan 2017 11:47:58 +0100 Subject: [PATCH] =?UTF-8?q?1=C2=B0=20part=20of=20migration=20to=20default?= =?UTF-8?q?=20chocolatey=20folder=20for=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BuildScripts/AppVeyor-Build.ps1 | 1 + .../Pretzel/chocolateyBeforeModify.ps1 | 30 +++++++++++++++++++ tools/chocolatey/Pretzel/pretzel.nuspec | 3 ++ 3 files changed, 34 insertions(+) create mode 100644 tools/chocolatey/Pretzel/chocolateyBeforeModify.ps1 diff --git a/BuildScripts/AppVeyor-Build.ps1 b/BuildScripts/AppVeyor-Build.ps1 index 984dff678..6e65ec12a 100644 --- a/BuildScripts/AppVeyor-Build.ps1 +++ b/BuildScripts/AppVeyor-Build.ps1 @@ -96,6 +96,7 @@ function CreatePackage($versionInfos) Copy-Item $tools\chocolatey\Pretzel\pretzel.nuspec chocoTemp\Pretzel\pretzel.nuspec Copy-Item $tools\chocolatey\Pretzel\chocolateyInstall.ps1 chocoTemp\Pretzel\tools\chocolateyInstall.ps1 Copy-Item $tools\chocolatey\Pretzel\chocolateyUninstall.ps1 chocoTemp\Pretzel\tools\chocolateyUninstall.ps1 + Copy-Item $tools\chocolatey\Pretzel\chocolateyBeforeModify.ps1 chocoTemp\Pretzel\tools\chocolateyBeforeModify.ps1 ReplaceChocoInstInfos chocoTemp\Pretzel\tools\chocolateyInstall.ps1 $version $tag $artifacts\Pretzel.$version.zip diff --git a/tools/chocolatey/Pretzel/chocolateyBeforeModify.ps1 b/tools/chocolatey/Pretzel/chocolateyBeforeModify.ps1 new file mode 100644 index 000000000..1aef284cb --- /dev/null +++ b/tools/chocolatey/Pretzel/chocolateyBeforeModify.ps1 @@ -0,0 +1,30 @@ +Write-Debug "Migrate Pretzel from BinRoot to normal Chocolatey directory" + +$binRoot = Get-BinRoot +$installDir = Join-Path $binRoot "Pretzel" + +# Remove folder +If (Test-Path $installDir){ + Remove-Item $installDir -Recurse +} + +# Remove path + +# get the PATH variable +$envPath = $env:PATH +$pathType = [System.EnvironmentVariableTarget]::User + +if ($envPath.ToLower().Contains($installDir.ToLower())) +{ + $statementTerminator = ";" + Write-Debug "PATH environment variable contains old pretzel path $installDir. Removing..." + $actualPath = [System.Collections.ArrayList](Get-EnvironmentVariable -Name 'Path' -Scope $pathType).split($statementTerminator) + + $actualPath.Remove($installDir) + $newPath = $actualPath -Join $statementTerminator + + Set-EnvironmentVariable -Name 'Path' -Value $newPath -Scope $pathType + +} else { + Write-Debug " The path to uninstall `'$installDir`' was not found in the `'$pathType`' PATH. Could not remove." +} \ No newline at end of file diff --git a/tools/chocolatey/Pretzel/pretzel.nuspec b/tools/chocolatey/Pretzel/pretzel.nuspec index d5d73de1a..617047d9c 100644 --- a/tools/chocolatey/Pretzel/pretzel.nuspec +++ b/tools/chocolatey/Pretzel/pretzel.nuspec @@ -13,5 +13,8 @@ A simple, pluggable site generation tool for .NET developers and Windows users Jekyll Liquid Razor Markdown blog hmtl static site engine https://github.com/Code52/pretzel/releases + + + \ No newline at end of file