-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchoco-install.ps1
More file actions
executable file
·30 lines (27 loc) · 1.62 KB
/
choco-install.ps1
File metadata and controls
executable file
·30 lines (27 loc) · 1.62 KB
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
29
30
function Save-ChocoPackage {
param (
$PackageName
)
Rename-Item -Path "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nupkg" -NewName "$PackageName.nupkg.zip" -ErrorAction:SilentlyContinue
Expand-Archive -LiteralPath "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nupkg.zip" -DestinationPath "$env:ChocolateyInstall\lib\$PackageName" -Force
Remove-Item "$env:ChocolateyInstall\lib\$PackageName\_rels" -Recurse
Remove-Item "$env:ChocolateyInstall\lib\$PackageName\package" -Recurse
Remove-Item "$env:ChocolateyInstall\lib\$PackageName\[Content_Types].xml"
New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey\$PackageName" -ItemType "directory" -ErrorAction:SilentlyContinue
choco pack "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nuspec" --outdir "${PSScriptRoot}\..\tmp\chocolatey\$PackageName"
}
# Check for existence of required environment variables
if ( $null -eq $env:ChocolateyInstall ) {
[Console]::Error.WriteLine('Missing $env:ChocolateyInstall environment variable')
exit 1
}
# Add the cached packages with source priority 1 (Chocolatey community is 0)
New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey" -ItemType "directory" -ErrorAction:SilentlyContinue
choco source add --name="cache" --source="${PSScriptRoot}\..\tmp\chocolatey" --priority=1
# Install nodejs v20.5.1 (will use cache if exists)
$nodejs = "nodejs.install"
choco install "$nodejs" --version="20.5.1" --require-checksums -y
# Internalise nodejs to cache if doesn't exist
if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs\$nodejs.20.5.1.nupkg" -PathType Leaf) ) {
Save-ChocoPackage -PackageName $nodejs
}