Skip to content

Commit

Permalink
Create rollback-yarn-1.10.0.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner authored Jul 28, 2020
1 parent 25d243e commit f6b39b0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/rollback-yarn-1.10.0.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function GetUninstallString($productName) {
$x64items = @(Get-ChildItem "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
($x64items + @(Get-ChildItem "HKLM:SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall") `
| ForEach-object { Get-ItemProperty Microsoft.PowerShell.Core\Registry::$_ } `
| Where-Object { $_.DisplayName -and $_.DisplayName.Contains($productName) } `
| Select UninstallString).UninstallString
}

$uninstallCommand = GetUninstallString "Yarn"

if ($uninstallCommand) {
Write-Host "Uninstalling existing installation of Yarn ..." -ForegroundColor Cyan

$uninstallCommand = $uninstallCommand.replace('MsiExec.exe /I{', '/x{').replace('MsiExec.exe /X{', '/x{')
cmd /c start /wait msiexec.exe $uninstallCommand /quiet

Write-Host "Uninstalled" -ForegroundColor Green
}

Write-Host "Installing Yarn..." -ForegroundColor Cyan
$msiPath = "$($env:TEMP)\yarn.msi"

Write-Host "Downloading..."
(New-Object Net.WebClient).DownloadFile('https://github.com/yarnpkg/yarn/releases/download/v1.10.0/yarn-1.10.0.msi', $msiPath)

Write-Host "Installing..."
cmd /c start /wait msiexec /i $msiPath /quiet /qn
del $msiPath

Write-Host "Yarn installed" -ForegroundColor Green

yarn --version

0 comments on commit f6b39b0

Please sign in to comment.