Skip to content

Commit

Permalink
feat: catch the addPath failure
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 18, 2021
1 parent 87beee7 commit 882d0f7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cppcheck/cppcheck.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addPath } from "@actions/core"
import { addPath } from "../utils/path/addPath"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
Expand Down
2 changes: 1 addition & 1 deletion src/doxygen/doxygen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addPath } from "@actions/core"
import { addPath } from "../utils/path/addPath"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
Expand Down
3 changes: 2 additions & 1 deletion src/gcc/gcc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { addPath, exportVariable, info } from "@actions/core"
import { exportVariable, info } from "@actions/core"
import { addPath } from "../utils/path/addPath"
import { existsSync } from "fs"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
Expand Down
2 changes: 1 addition & 1 deletion src/opencppcoverage/opencppcoverage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addPath } from "@actions/core"
import { addPath } from "../utils/path/addPath"
import { setupChocoPack } from "../utils/setup/setupChocoPack"

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
15 changes: 15 additions & 0 deletions src/utils/path/addPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { addPath as ghAddPath } from "@actions/core"
import { delimiter } from "path"
import * as core from "@actions/core"

/** An add path function that works locally or inside GitHub Actions */
export function addPath(path: string) {
try {
ghAddPath(path)
} catch (err) {
core.error(err as Error)
core.error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
// TODO shell out to add path
}
}
3 changes: 2 additions & 1 deletion src/utils/setup/setupBin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { find, downloadTool, cacheDir } from "@actions/tool-cache"
import { addPath, info } from "@actions/core"
import { info } from "@actions/core"
import { addPath } from "../path/addPath"
import { join } from "path"
import { existsSync } from "fs"
import * as hasha from "hasha"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/setup/setupChocoPack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable require-atomic-updates */
import { addPath } from "@actions/core"
import { addPath } from "../path/addPath"
import which from "which"
import { setupChocolatey } from "../../chocolatey/chocolatey"
import { InstallationInfo } from "./setupBin"
Expand Down
3 changes: 2 additions & 1 deletion src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { getExecOutput } from "@actions/exec"
import spawn from "cross-spawn"
import which from "which"
import { addPath, info } from "@actions/core"
import { info } from "@actions/core"
import { addPath } from "../path/addPath"
import { setupPython } from "../../python/python"
import { isBinUptoDate } from "./version"
import { join } from "path"
Expand Down

0 comments on commit 882d0f7

Please sign in to comment.