From f6b39b022e8a16d560b50c6616a8cbab47fdccd2 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Tue, 28 Jul 2020 09:33:17 -0700 Subject: [PATCH] Create rollback-yarn-1.10.0.ps1 --- scripts/rollback-yarn-1.10.0.ps1 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/rollback-yarn-1.10.0.ps1 diff --git a/scripts/rollback-yarn-1.10.0.ps1 b/scripts/rollback-yarn-1.10.0.ps1 new file mode 100644 index 0000000..3ebc7ca --- /dev/null +++ b/scripts/rollback-yarn-1.10.0.ps1 @@ -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