-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathoptions.ts
42 lines (38 loc) · 1.21 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { getInput } from "@actions/core"
import type { AddPathOptions } from "envosman"
import { untildifyUser } from "untildify-user"
import type { Inputs } from "./tool.ts"
import type { InstallationInfo } from "./utils/setup/setupBin.ts"
/**
* The options for the setup-cpp function
*/
export type Opts = Partial<Record<Inputs, string | undefined>> & {
"setup-cpp"?: boolean
timeout?: string
"node-package-manager"?: string
}
/** Get an object from github actions */
export function maybeGetInput(key: string) {
const value = getInput(key.toLowerCase())
if (value !== "false" && value !== "") {
return value
}
return undefined // skip installation
}
export function getSuccessMessage(tool: string, installationInfo: InstallationInfo | undefined | void) {
let msg = `✅ ${tool} was installed successfully:`
if (installationInfo === undefined) {
return msg
}
if ("installDir" in installationInfo) {
msg += `\n- The installation directory is ${installationInfo.installDir}`
}
if (installationInfo.binDir !== "") {
msg += `\n- The binary directory is ${installationInfo.binDir}`
}
return msg
}
export const rcOptions: AddPathOptions = {
rcPath: untildifyUser("~/.cpprc"),
guard: "cpp",
}