fix: fix the platform name for ninja

This commit is contained in:
Amin Yahyaabadi 2021-09-14 03:06:51 -05:00
parent e55608c34b
commit 15879e9212
1 changed files with 16 additions and 2 deletions

View File

@ -5,11 +5,25 @@ import { existsSync } from "fs"
import * as hasha from "hasha" import * as hasha from "hasha"
import { tmpdir } from "os" import { tmpdir } from "os"
/** Get the platform name Ninja uses in their download links */
function getNinjaPlatform(platform: NodeJS.Platform) {
switch (platform) {
case "win32":
return "win"
case "darwin":
return "mac"
case "linux":
return "linux"
default:
throw new Error(`Unsupported platform '${platform}'`)
}
}
export async function setupNinja(version: string): Promise<string> { export async function setupNinja(version: string): Promise<string> {
const platform = process.platform const platform = getNinjaPlatform(process.platform)
// Build artifact name // Build artifact name
const ninjaBin = platform === "win32" ? "ninja.exe" : "ninja" const ninjaBin = platform === "win" ? "ninja.exe" : "ninja"
// Restore from cache (if found). // Restore from cache (if found).
const ninjaDir = find("ninja", version) const ninjaDir = find("ninja", version)