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 { getExecOutput } from "@actions/exec"
import * as core from "@actions/core"
import { addEnv } from "../utils/env/addEnv" import { addEnv } from "../utils/env/addEnv"
import { error } from "../utils/io/io"
export async function setupMacOSSDK() { export async function setupMacOSSDK() {
if (process.platform === "darwin") { if (process.platform === "darwin") {
@ -10,10 +10,10 @@ export async function setupMacOSSDK() {
if (sdkroot) { if (sdkroot) {
addEnv("SDKROOT", sdkroot.trim()) addEnv("SDKROOT", sdkroot.trim())
} else { } else {
core.error(`SDKROOT not set`) error(`SDKROOT not set`)
} }
} catch (e) { } 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 { appendFileSync } from "fs"
import { join } from "path" import { join } from "path"
import { isRoot } from "./sudo" import { isRoot } from "./sudo"
import { error } from "../io/io"
/** An add path function that works locally or inside GitHub Actions */ /** An add path function that works locally or inside GitHub Actions */
export function addEnv(name: string, val: string | undefined) { export function addEnv(name: string, val: string | undefined) {
@ -17,12 +18,12 @@ export function addEnv(name: string, val: string | undefined) {
} }
} catch (err) { } catch (err) {
try { try {
core.error(err as Error) error(err as Error)
return addEnvSystem(name, val) return addEnvSystem(name, val)
} catch (err2) { } 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

@ -5,6 +5,7 @@ import execa from "execa"
import { isGitHubCI } from "../env/isci" import { isGitHubCI } from "../env/isci"
import { untildify_user as untildify } from "./untildify" import { untildify_user as untildify } from "./untildify"
import { appendFileSync } from "fs" import { appendFileSync } from "fs"
import { error } from "../io/io"
/** An add path function that works locally or inside GitHub Actions */ /** An add path function that works locally or inside GitHub Actions */
export function addPath(path: string) { export function addPath(path: string) {
@ -16,12 +17,12 @@ export function addPath(path: string) {
} }
} catch (err) { } catch (err) {
try { try {
core.error(err as Error) error(err as Error)
return addPathSystem(path) return addPathSystem(path)
} catch (err2) { } 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.`)
} }
} }