fix(chrome installers): Check for existence

- Don't launch Chrome installers if they're already
    installed
 - Heuristic for Canary is a path check
 - Heuristic for dev channel is path check + reg key
This commit is contained in:
Iristyle
2013-04-03 12:28:08 -04:00
parent 2f854eaadf
commit 8d03388413
4 changed files with 49 additions and 8 deletions

View File

@@ -24,6 +24,7 @@
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="..\core\ChromeHelpers.ps1" target="tools" />
<file src="tools\**" target="tools" />
</files>
</package>

View File

@@ -2,9 +2,25 @@ $package = 'Chrome.Canary'
try {
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
. (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1')
$installedPath = Get-ChromePath -Canary
if (Test-Path $installedPath)
{
Write-Host "Chrome Canary already installed at $installedPath"
}
else
{
$url = 'https://dl.google.com/tag/s/appguid%3D%7B4ea16ac7-fd5a-47c3-875b-dbf4a2008c20%7D%26iid%3D%7B0281A7E2-6043-D983-8BBA-7FD622493C9D%7D%26lang%3Den%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%2520Canary%26needsadmin%3Dfalse/update2/installers/ChromeSetup.exe'
Install-ChocolateyPackage 'ChromeSetup' 'exe' '' $url
}
Write-ChocolateySuccess $package
} catch {

View File

@@ -19,6 +19,7 @@
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="..\core\ChromeHelpers.ps1" target="tools" />
<file src="tools\**" target="tools" />
</files>
</package>

View File

@@ -2,6 +2,28 @@ $package = 'Chrome.Dev'
try {
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
. (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1')
$installedPath = Get-ChromePath
$params = @{
Path = 'HKCU:\Software\Google\Update\ClientState\{8A69D345-D564-463C-AFF1-A69D9E530F96}';
Name = 'ap';
ErrorAction = 'SilentlyContinue';
}
$installType = Get-ItemProperty @params | Select -ExpandProperty 'ap'
if ((Test-Path $installedPath) -and ($installType -match 'dev'))
{
Write-Host "Chrome Dev already installed at $installedPath"
}
else
{
$params = @{
PackageName = $package;
FileType = 'exe';
@@ -10,6 +32,7 @@ try {
}
Install-ChocolateyPackage @params
}
Write-ChocolateySuccess $package
} catch {