fix: use colored errors for local usage

This commit is contained in:
Amin Yahyaabadi 2022-01-29 15:15:35 -08:00
parent 10770915e5
commit a67e7babf2
6 changed files with 14 additions and 12 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

@ -1,6 +1,6 @@
import { getExecOutput } from "@actions/exec"
import * as core from "@actions/core"
import { addEnv } from "../utils/env/addEnv"
import { error } from "../utils/io/io"
export async function setupMacOSSDK() {
if (process.platform === "darwin") {
@ -10,10 +10,10 @@ export async function setupMacOSSDK() {
if (sdkroot) {
addEnv("SDKROOT", sdkroot.trim())
} else {
core.error(`SDKROOT not set`)
error(`SDKROOT not set`)
}
} catch (e) {
core.error(e as Error | string)
error(e as Error | string)
}
}
}

View File

@ -6,6 +6,7 @@ import { untildify_user as untildify } from "../path/untildify"
import { appendFileSync } from "fs"
import { join } from "path"
import { isRoot } from "./sudo"
import { error } from "../io/io"
/** An add path function that works locally or inside GitHub Actions */
export function addEnv(name: string, val: string | undefined) {
@ -17,12 +18,12 @@ export function addEnv(name: string, val: string | undefined) {
}
} catch (err) {
try {
core.error(err as Error)
error(err as Error)
return addEnvSystem(name, val)
} catch (err2) {
core.error(err2 as Error)
error(err2 as Error)
}
core.error(`Failed to export environment variable ${name}=${val}. You should add it manually.`)
error(`Failed to export environment variable ${name}=${val}. You should add it manually.`)
}
}

View File

@ -11,4 +11,4 @@ export function success(msg: string) {
export function warning(msg: string) {
return isGitHubCI() ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
}
}

View File

@ -5,6 +5,7 @@ import execa from "execa"
import { isGitHubCI } from "../env/isci"
import { untildify_user as untildify } from "./untildify"
import { appendFileSync } from "fs"
import { error } from "../io/io"
/** An add path function that works locally or inside GitHub Actions */
export function addPath(path: string) {
@ -16,12 +17,12 @@ export function addPath(path: string) {
}
} catch (err) {
try {
core.error(err as Error)
error(err as Error)
return addPathSystem(path)
} catch (err2) {
core.error(err2 as Error)
error(err2 as Error)
}
core.error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
}
}