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
|
||||
|
||||
let osVersion: number[] | null = null
|
||||
try {
|
||||
// get the version if not already done
|
||||
osVersion = await ubuntuVersion()
|
||||
} catch (err) {
|
||||
warning((err as Error).toString())
|
||||
}
|
||||
const osVersion = await ubuntuVersion()
|
||||
|
||||
// sync the version for the llvm tools
|
||||
if (!syncVersions(opts, ["llvm", "clangtidy", "clangformat"])) {
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
import { warning } from "ci-log"
|
||||
import { getUbuntuVersion } from "ubuntu-version"
|
||||
import which from "which"
|
||||
import { setupAptPack } from "../setup/setupAptPack"
|
||||
import { isUbuntu } from "./isUbuntu"
|
||||
|
||||
export async function ubuntuVersion(): Promise<number[] | null> {
|
||||
if (isUbuntu()) {
|
||||
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
||||
await setupAptPack("lsb-release")
|
||||
}
|
||||
const versionSplitted = await getUbuntuVersion()
|
||||
try {
|
||||
if (isUbuntu()) {
|
||||
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
||||
await setupAptPack("lsb-release")
|
||||
}
|
||||
const versionSplitted = await getUbuntuVersion()
|
||||
|
||||
if (versionSplitted.length === 0) {
|
||||
throw new Error("Failed to get the ubuntu major version.")
|
||||
}
|
||||
if (versionSplitted.length === 0) {
|
||||
warning("Failed to get the ubuntu major version.")
|
||||
return null
|
||||
}
|
||||
|
||||
return versionSplitted
|
||||
} else {
|
||||
return versionSplitted
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
} catch (err) {
|
||||
warning((err as Error).toString())
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue