Permalink
Browse files

Merge pull request #112 from Redsandro/patch-3

Update PhantomJS to fix binRoot detection
  • Loading branch information...
2 parents aaab696 + b04c711 commit 6ec03f627773b8cf4ef5082e4770f2a8d064cce4 @ferventcoder committed Nov 11, 2013
Showing with 42 additions and 4 deletions.
  1. +35 −0 phantomjs/tools/Get-BinRoot.ps1
  2. +7 −4 phantomjs/tools/chocolateyInstall.ps1
@@ -0,0 +1,35 @@
+function Get-BinRoot {
+
+ # Since CamelCase was decided upon when $env:ChocolateyInstall was first invented, whe should stick to this convention and use $env:ChocolateyBinRoot.
+ # I propose:
+ # 1) all occurances of $env:chocolatey_bin_root be replaced with $env:ChocolateyBinRoot;
+ # 2) Make the new Chocolatey Installer for new users explicitly set (if not exists) $env:ChocolateyInstall and $env:ChocolateyBinRoot as environment variables so users will smile and understand;
+ # 3) Make new Chocolatey convert old $env:chocolatey_bin_root to $env:ChocolateyBinRoot
+
+ # For now, check old var first
+ if($env:ChocolateyBinRoot -eq $null) { # If no value
+ if($env:chocolatey_bin_root -eq $null) { # Try old var
+ $binRoot = "$env:ChocolateyInstall\bin"
+ }
+ else {
+ $env:ChocolateyBinRoot = $env:chocolatey_bin_root
+ }
+ }
+
+ # My ChocolateyBinRoot is C:\Common\bin, but looking at other packages, not everyone assumes ChocolateyBinRoot is prepended with a drive letter.
+ if (-not($env:ChocolateyBinRoot -imatch "^\w:")) {
+ # Add drive letter
+ $binRoot = join-path $env:systemdrive $env:ChocolateyBinRoot
+ }
+ else {
+ $binRoot = $env:ChocolateyBinRoot
+ }
+
+ # Now that we figured out the binRoot, let's store it as per proposal #3 line #7
+ if(-not($env:ChocolateyBinRoot -eq $binRoot)) {
+ [Environment]::SetEnvironmentVariable("ChocolateyBinRoot", "$binRoot", "User")
+ # Note that user variables pose a problem when there are two admins on one computer. But this is what was decided upon.
+ }
+
+ return $binRoot
+}
@@ -3,10 +3,13 @@ try {
$version = '1.9.2'
$installDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
- ### For BinRoot, use the following instead ###
- $binRoot = "$env:systemdrive\"
- ### Using an environment variable to to define the bin root until we implement configuration ###
- if($env:chocolatey_bin_root -ne $null){$binRoot = join-path $env:systemdrive $env:chocolatey_bin_root}
+
+ # Temporary include function until it is included with Chocolatey
+ Import-Module "$($pwd)\Get-BinRoot.ps1"
+
+ # Get $binRoot until we implement YAML configuration
+ $binRoot = Get-BinRoot
+
$installDir = Join-Path $binRoot $package
Write-Host "Adding `'$installDir`' to the path and the current shell path"
Install-ChocolateyPath "$installDir"

0 comments on commit 6ec03f6

Please sign in to comment.