fix: add isUbuntu and skip getting ubuntu version on arch

This commit is contained in:
Amin Yahyaabadi 2022-06-29 20:37:50 -07:00
parent f3cbe53fbc
commit 729ae041fc
5 changed files with 22 additions and 3 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,9 @@ import which from "which"
let isArchCache: undefined | boolean = undefined
export function isArch(): boolean {
if (process.platform !== "linux") {
return false
}
if (isArchCache === undefined) {
// detect arch by checking if pacman exists
isArchCache = which.sync("pacman", { nothrow: true }) !== null

15
src/utils/env/isUbuntu.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import which from "which"
let isUbuntuCache: undefined | boolean = undefined
export function isUbuntu(): boolean {
if (process.platform !== "linux") {
return false
}
if (isUbuntuCache === undefined) {
const apt = "apt-get"
isUbuntuCache = which.sync(apt, { nothrow: true }) !== null
}
return isUbuntuCache
}

View File

@ -1,7 +1,8 @@
import { getUbuntuVersion } from "ubuntu-version"
import { isUbuntu } from "./isUbuntu"
export async function ubuntuVersion(): Promise<number[] | null> {
if (process.platform === "linux") {
if (isUbuntu()) {
const versionSplitted = await getUbuntuVersion()
if (versionSplitted.length === 0) {