-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-631) Remove Get-BinRoot, Add Get-ToolsLocation
Get-ToolsLocation is the successor to Get-BinRoot. It sets an alias to the old method and provides the deprecation message when this method is called with the older alias. Get-ToolsLocation is a much more aptly named value, and the environment variable surrounding it makes sense upon sight. If either of the older environment variables are found, they are used to update this value and then those older environment variables are removed. This also resolves GH-628, the tools location can be the root of the drive again.
- Loading branch information
1 parent
968f130
commit c014357
Showing
3 changed files
with
58 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
src/chocolatey.resources/helpers/functions/Get-BinRoot.ps1
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
src/chocolatey.resources/helpers/functions/Get-ToolsLocation.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2011 - Present RealDimensions Software, LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
function Get-ToolsLocation { | ||
Write-Debug "Running 'Get-ToolsLocation'"; | ||
$invocation = $MyInvocation | ||
if ($invocation -ne $null -and $invocation.InvocationName -ne $null -and $invocation.InvocationName.ToLower() -eq 'Get-BinRoot') { | ||
Write-Host "Get-BinRoot is going to be deprecated in v1 and removed in v2. It is being replaced with Get-ToolsLocation, however many packages no longer require a special separate directory since package folders no longer have versions on them. Some do though and should continue to use Get-ToolsLocation." | ||
} | ||
|
||
$toolsLocation = $env:ChocolateyToolsLocation | ||
|
||
if ($toolsLocation -eq $null) { | ||
$binRoot = $env:ChocolateyBinRoot | ||
$olderRoot = $env:chocolatey_bin_root | ||
|
||
if ($binRoot -eq $null -and $olderRoot -eq $null) { | ||
$toolsLocation = Join-Path $env:systemdrive 'tools' | ||
} else { | ||
if ($olderRoot -ne $null) { | ||
if ($binRoot -eq $null) { | ||
$binRoot = $olderRoot | ||
} | ||
Set-EnvironmentVariable -Name "chocolatey_bin_root" -Value '' -Scope User | ||
} | ||
|
||
$toolsLocation = $binRoot | ||
Set-EnvironmentVariable -Name "ChocolateyBinRoot" -Value '' -Scope User | ||
} | ||
} | ||
|
||
# Add a drive letter if one doesn't exist | ||
if (-not($toolsLocation -imatch "^\w:")) { | ||
$toolsLocation = join-path $env:systemdrive $toolsLocation | ||
} | ||
|
||
if (-not($env:ChocolateyToolsLocation -eq $toolsLocation)) { | ||
Set-EnvironmentVariable -Name "ChocolateyToolsLocation" -Value $toolsLocation -Scope User | ||
} | ||
|
||
return $toolsLocation | ||
} | ||
|
||
Set-Alias Get-BinRoot Get-ToolsLocation -Force -Scope Global -Option AllScope |