mirror of https://github.com/aminya/setup-cpp
chore: make ubuntuVersion exception safe
This commit is contained in:
parent
b9c2f3b391
commit
23a09cba35
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
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
|
@ -148,13 +148,7 @@ export async function main(args: string[]): Promise<number> {
|
||||||
|
|
||||||
// installing the specified tools
|
// installing the specified tools
|
||||||
|
|
||||||
let osVersion: number[] | null = null
|
const osVersion = await ubuntuVersion()
|
||||||
try {
|
|
||||||
// get the version if not already done
|
|
||||||
osVersion = await ubuntuVersion()
|
|
||||||
} catch (err) {
|
|
||||||
warning((err as Error).toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
// sync the version for the llvm tools
|
// sync the version for the llvm tools
|
||||||
if (!syncVersions(opts, ["llvm", "clangtidy", "clangformat"])) {
|
if (!syncVersions(opts, ["llvm", "clangtidy", "clangformat"])) {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import { warning } from "ci-log"
|
||||||
import { getUbuntuVersion } from "ubuntu-version"
|
import { getUbuntuVersion } from "ubuntu-version"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { setupAptPack } from "../setup/setupAptPack"
|
import { setupAptPack } from "../setup/setupAptPack"
|
||||||
import { isUbuntu } from "./isUbuntu"
|
import { isUbuntu } from "./isUbuntu"
|
||||||
|
|
||||||
export async function ubuntuVersion(): Promise<number[] | null> {
|
export async function ubuntuVersion(): Promise<number[] | null> {
|
||||||
|
try {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
||||||
await setupAptPack("lsb-release")
|
await setupAptPack("lsb-release")
|
||||||
|
@ -11,11 +13,16 @@ export async function ubuntuVersion(): Promise<number[] | null> {
|
||||||
const versionSplitted = await getUbuntuVersion()
|
const versionSplitted = await getUbuntuVersion()
|
||||||
|
|
||||||
if (versionSplitted.length === 0) {
|
if (versionSplitted.length === 0) {
|
||||||
throw new Error("Failed to get the ubuntu major version.")
|
warning("Failed to get the ubuntu major version.")
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return versionSplitted
|
return versionSplitted
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
warning((err as Error).toString())
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue