mirror of https://github.com/aminya/setup-cpp
fix: only cache if in ci
This commit is contained in:
parent
d81b44b112
commit
418fa80b65
|
@ -5,6 +5,7 @@ import { join } from "path"
|
|||
import { existsSync } from "fs"
|
||||
import * as hasha from "hasha"
|
||||
import { tmpdir } from "os"
|
||||
import { isCI } from "../env/isci"
|
||||
|
||||
/** A type that describes a package */
|
||||
export type PackageInfo = {
|
||||
|
@ -47,6 +48,7 @@ export async function setupBin(
|
|||
const { url, binRelativeDir, extractedFolderName, extractFunction } = await getPackageInfo(version, process.platform)
|
||||
|
||||
// Restore from cache (if found).
|
||||
if (isCI()) {
|
||||
try {
|
||||
const dir = find(name, version)
|
||||
if (dir) {
|
||||
|
@ -59,6 +61,7 @@ export async function setupBin(
|
|||
} catch {
|
||||
// fails on a local machine?
|
||||
}
|
||||
}
|
||||
|
||||
// Get an unique output directory name from the URL.
|
||||
const key: string = await hasha.async(url, { algorithm: "md5" })
|
||||
|
@ -80,7 +83,7 @@ export async function setupBin(
|
|||
await addPath(binDir)
|
||||
|
||||
// check if inside Github Actions. If so, cache the installation
|
||||
if (typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
if (isCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
await cacheDir(rootDir, name, version)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue