feat: Elixir 0.10.0 package first release
- ensure Erlang and toolsroot are installed - add bin directory to PATH - uninstall removes Elixir from tools directory and removes PATH mods
This commit is contained in:
36
Elixir/tools/chocolateyInstall.ps1
Normal file
36
Elixir/tools/chocolateyInstall.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
$package = 'Elixir'
|
||||
$version = '0.10.0'
|
||||
|
||||
try {
|
||||
$params = @{
|
||||
PackageName = $package;
|
||||
FileType = 'zip';
|
||||
Url = "https://github.com/elixir-lang/elixir/releases/download/v$version/v$version.zip";
|
||||
UnzipLocation = Join-Path $Env:SystemDrive 'tools';
|
||||
}
|
||||
|
||||
$binRoot = Join-Path $Env:SystemDrive $Env:Chocolatey_Bin_Root
|
||||
if (Test-Path $binRoot)
|
||||
{
|
||||
$params.UnzipLocation = $binRoot
|
||||
}
|
||||
|
||||
$params.UnzipLocation = Join-Path $params.UnzipLocation 'Elixir'
|
||||
|
||||
if (!(Test-Path($params.UnzipLocation)))
|
||||
{
|
||||
New-Item $params.UnzipLocation -Type Directory | Out-Null
|
||||
}
|
||||
|
||||
Install-ChocolateyZipPackage @params
|
||||
|
||||
$elixirBin = Join-Path $params.UnzipLocation 'bin'
|
||||
|
||||
Install-ChocolateyPath $elixirBin
|
||||
|
||||
Write-ChocolateySuccess $package
|
||||
} catch {
|
||||
Write-ChocolateyFailure $package "$($_.Exception.Message)"
|
||||
throw
|
||||
}
|
||||
|
35
Elixir/tools/chocolateyUninstall.ps1
Normal file
35
Elixir/tools/chocolateyUninstall.ps1
Normal file
@@ -0,0 +1,35 @@
|
||||
$package = 'Elixir'
|
||||
|
||||
try {
|
||||
$location = Join-Path $Env:SystemDrive $Env:Chocolatey_Bin_Root
|
||||
if (!(Test-Path $location))
|
||||
{
|
||||
$location = Join-Path $Env:SystemDrive 'tools'
|
||||
}
|
||||
$location = Join-Path $location $package
|
||||
|
||||
if (Test-Path $location)
|
||||
{
|
||||
Remove-Item $location -Recurse -Force
|
||||
}
|
||||
|
||||
$binLocation = (Join-Path $location 'bin') -replace '\\', '\\'
|
||||
|
||||
$userPaths = [Environment]::GetEnvironmentVariable('Path', 'User') -split ';' |
|
||||
? { ($_ -notmatch $binLocation) -and (![String]::IsNullOrEmpty($_)) } |
|
||||
Select-Object -Unique
|
||||
|
||||
[Environment]::SetEnvironmentVariable('Path', ($userPaths -join ';'), 'User')
|
||||
|
||||
Write-Host @'Please restart your current shell session to access Elixir commands:
|
||||
elixir
|
||||
elixirc
|
||||
mix
|
||||
iex.bat (use batch file within Powershell due to name collision)
|
||||
'@
|
||||
|
||||
Write-ChocolateySuccess $package
|
||||
} catch {
|
||||
Write-ChocolateyFailure $package "$($_.Exception.Message)"
|
||||
throw
|
||||
}
|
Reference in New Issue
Block a user