Skip to content

Commit

Permalink
fix: use colored errors for local usage
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 29, 2022
1 parent 1077091 commit a67e7ba
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/macos-sdk/macos-sdk.ts
Original file line number Diff line number Diff line change
@@ -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") {
Expand All @@ -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)
}
}
}
7 changes: 4 additions & 3 deletions src/utils/env/addEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/io/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
}
7 changes: 4 additions & 3 deletions src/utils/path/addPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.`)
}
}

Expand Down

0 comments on commit a67e7ba

Please sign in to comment.