fix: support ninja on Windows/Linux arm

This commit is contained in:
Amin Yahyaabadi 2024-09-08 03:34:24 -07:00
parent 6003b39332
commit d95a1c182b
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
5 changed files with 20 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,24 +1,34 @@
import { addExeExt } from "patha"
import { arm64, x86, x86_64 } from "../utils/env/arch.js"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
/** Get the platform name Ninja uses in their download links */
function getNinjaPlatform(platform: NodeJS.Platform) {
function getNinjaPlatformArch(platform: NodeJS.Platform, arch: string) {
switch (platform) {
case "win32":
return "win"
return x86_64.includes(arch)
|| x86.includes(arch)
? "win"
: arm64.includes(arch)
? "winarm64"
: "win"
case "darwin":
return "mac"
case "linux":
return "linux"
return x86_64.includes(arch)
|| x86.includes(arch)
? "linux"
: arm64.includes(arch)
? "linux-aarch64"
: "linux"
default:
throw new Error(`Unsupported platform '${platform}'`)
}
}
/** Get the platform data for ninja */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getNinjaPackageInfo(version: string, platform: NodeJS.Platform, _arch: string): PackageInfo {
const ninjaPlatform = getNinjaPlatform(platform)
function getNinjaPackageInfo(version: string, platform: NodeJS.Platform, arch: string): PackageInfo {
const ninjaPlatform = getNinjaPlatformArch(platform, arch)
return {
binRelativeDir: "",
binFileName: addExeExt("ninja"),