forked from atom/fs-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload-node-lib-win-arm64.ps1
36 lines (28 loc) · 1.45 KB
/
download-node-lib-win-arm64.ps1
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
31
32
33
34
35
36
# This script can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
$nodeVersion = $args[0]
$fallbackVersion = $args[1]
If ($null -eq $nodeVersion -Or $null -eq $fallbackVersion) {
Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 NODE_VERSION NODE_FALLBACK_VERSION"
exit 1
}
$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib"
$fallbackUrl = "https://unofficial-builds.nodejs.org/download/release/v$fallbackVersion/win-arm64/node.lib"
# Always write to the $nodeVersion cache folder, even if we're using the fallbackVersion
$cacheFolder = "$env:TEMP\prebuild\napi\$nodeVersion\arm64"
If (!(Test-Path $cacheFolder)) {
New-Item -ItemType Directory -Force -Path $cacheFolder
}
$output = "$cacheFolder\node.lib"
$start_time = Get-Date
Try {
Invoke-WebRequest -Uri $url -OutFile $output
$downloadedNodeVersion = $nodeVersion
} Catch {
If ($_.Exception.Response -And $_.Exception.Response.StatusCode -eq "NotFound") {
Write-Output "No arm64 node.lib found for Node Windows $nodeVersion, trying fallback version $fallbackVersion..."
Invoke-WebRequest -Uri $fallbackUrl -OutFile $output
$downloadedNodeVersion = $fallbackVersion
}
}
Write-Output "Downloaded arm64 NodeJS lib v$downloadedNodeVersion to $output in $((Get-Date).Subtract($start_time).Seconds) second(s)"