-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathchocolateyinstall.ps1.in
More file actions
28 lines (25 loc) · 943 Bytes
/
Copy pathchocolateyinstall.ps1.in
File metadata and controls
28 lines (25 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ErrorActionPreference = 'Stop'; # stop on all errors
$packageName = 'yarn'
$packageArgs = @{
packageName = $packageName
softwareName = 'Yarn*'
fileType = 'msi'
silentArgs = "/qn /norestart /l*v `"$env:TEMP\chocolatey\$($packageName)\$($packageName).MsiInstall.log`""
validExitCodes = @(0, 3010, 1641)
checksumType = 'sha256'
url = 'https://yarnpkg.com/downloads/{VERSION}/yarn-{VERSION}.msi'
checksum = '{CHECKSUM}'
}
Install-ChocolateyPackage @packageArgs
# Update Yarn's package.json file so it can tell that it was installed via Chocolatey.
if (Test-Path "${env:ProgramFiles(x86)}\Yarn\package.json") {
$path = "${env:ProgramFiles(x86)}\Yarn\package.json"
} else {
$path = "$env:ProgramFiles\Yarn\package.json"
}
$script = @"
(Get-Content -Path '$path') ``
-replace 'installationMethod":.+', 'installationMethod": "choco",' ``
| Set-Content '$path'
"@
Start-ChocolateyProcessAsAdmin -Statements $script