fix: fix apt resolving on non-Linux

This commit is contained in:
Amin Yahyaabadi 2025-07-03 04:56:17 -07:00
parent 928af1ef3b
commit 0fa8654824
7 changed files with 11 additions and 11 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,6 +1,6 @@
{
"name": "setup-apt",
"version": "3.1.1",
"version": "3.1.2",
"description": "Setup apt packages and repositories in Debian/Ubuntu-based distributions",
"repository": "https://github.com/aminya/setup-cpp",
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-apt",

View File

@ -4,28 +4,28 @@ import which from "which"
* Check if nala is installed
*/
export function hasNala() {
return which.sync("nala", { nothrow: true }) !== null
return process.platform === "linux" && which.sync("nala", { nothrow: true }) !== null
}
/**
* Check if apt-fast is installed
*/
export function hasAptFast() {
return which.sync("apt-fast", { nothrow: true }) !== null
return process.platform === "linux" && which.sync("apt-fast", { nothrow: true }) !== null
}
/**
* Check if apt is installed
*/
export function hasApt() {
return which.sync("apt", { nothrow: true }) !== null
return process.platform === "linux" && which.sync("apt", { nothrow: true }) !== null
}
/**
* Check if apt-get is installed
*/
export function hasAptGet() {
return which.sync("apt-get", { nothrow: true }) !== null
return process.platform === "linux" && which.sync("apt-get", { nothrow: true }) !== null
}
/**

View File

@ -1,13 +1,13 @@
import { addEnv } from "envosman"
import semverMajor from "semver/functions/major"
import semverValid from "semver/functions/valid"
import { hasApt, installAptPack } from "setup-apt"
import { hasAptGet, installAptPack } from "setup-apt"
import { rcOptions } from "../options.js"
import { setupPipPack } from "../utils/setup/setupPipPack.js"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupGcovr(version: string | undefined, _setupDir: string, _arch: string) {
if (hasApt() && (version === undefined || version === "")) {
if (hasAptGet() && (version === undefined || version === "")) {
// use apt on Ubuntu/Debian if version is not specified
return installAptPack([{ name: "gcovr", version }])
}