2019-11-06 19:41:45 +01:00
|
|
|
import { Inputs } from "../constants";
|
|
|
|
|
|
|
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
2019-10-30 19:48:49 +01:00
|
|
|
function getInputName(name: string): string {
|
|
|
|
return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
|
|
|
|
}
|
|
|
|
|
2019-11-12 22:48:02 +01:00
|
|
|
export function setInput(name: string, value: string): void {
|
2019-10-30 19:48:49 +01:00
|
|
|
process.env[getInputName(name)] = value;
|
|
|
|
}
|
2019-11-06 19:41:45 +01:00
|
|
|
|
|
|
|
interface CacheInput {
|
|
|
|
path: string;
|
|
|
|
key: string;
|
|
|
|
restoreKeys?: string[];
|
2023-01-05 12:19:13 +01:00
|
|
|
enableCrossOsArchive?: boolean;
|
2023-01-30 12:10:58 +01:00
|
|
|
failOnCacheMiss?: boolean;
|
2023-03-09 13:30:28 +01:00
|
|
|
lookupOnly?: boolean;
|
2019-11-06 19:41:45 +01:00
|
|
|
}
|
|
|
|
|
2019-11-12 22:48:02 +01:00
|
|
|
export function setInputs(input: CacheInput): void {
|
2019-11-06 19:41:45 +01:00
|
|
|
setInput(Inputs.Path, input.path);
|
|
|
|
setInput(Inputs.Key, input.key);
|
|
|
|
input.restoreKeys &&
|
|
|
|
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
2023-01-05 12:19:13 +01:00
|
|
|
input.enableCrossOsArchive !== undefined &&
|
|
|
|
setInput(
|
|
|
|
Inputs.EnableCrossOsArchive,
|
|
|
|
input.enableCrossOsArchive.toString()
|
|
|
|
);
|
2023-01-30 12:10:58 +01:00
|
|
|
input.failOnCacheMiss !== undefined &&
|
|
|
|
setInput(Inputs.FailOnCacheMiss, input.failOnCacheMiss.toString());
|
2023-03-09 13:30:28 +01:00
|
|
|
input.lookupOnly !== undefined &&
|
|
|
|
setInput(Inputs.LookupOnly, input.lookupOnly.toString());
|
2019-11-06 19:41:45 +01:00
|
|
|
}
|
|
|
|
|
2019-11-12 22:48:02 +01:00
|
|
|
export function clearInputs(): void {
|
2019-11-06 19:41:45 +01:00
|
|
|
delete process.env[getInputName(Inputs.Path)];
|
|
|
|
delete process.env[getInputName(Inputs.Key)];
|
|
|
|
delete process.env[getInputName(Inputs.RestoreKeys)];
|
2020-10-02 16:59:55 +02:00
|
|
|
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
2023-01-05 12:19:13 +01:00
|
|
|
delete process.env[getInputName(Inputs.EnableCrossOsArchive)];
|
2023-01-30 12:10:58 +01:00
|
|
|
delete process.env[getInputName(Inputs.FailOnCacheMiss)];
|
2023-03-09 13:30:28 +01:00
|
|
|
delete process.env[getInputName(Inputs.LookupOnly)];
|
2019-11-06 19:41:45 +01:00
|
|
|
}
|