feat: catch the addPath failure

This commit is contained in:
Amin Yahyaabadi 2021-09-17 21:17:21 -05:00
parent 87beee7e7d
commit 882d0f7013
8 changed files with 25 additions and 7 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

15
src/utils/path/addPath.ts Normal file
View File

@ -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
}
}

View File

@ -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"

View File

@ -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"

View File

@ -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"