2019-11-07 02:41:45 +08:00
|
|
|
import { Inputs } from "../constants";
|
|
|
|
|
|
|
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
2019-10-31 02:48:49 +08:00
|
|
|
function getInputName(name: string): string {
|
|
|
|
return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setInput(name: string, value: string) {
|
|
|
|
process.env[getInputName(name)] = value;
|
|
|
|
}
|
2019-11-07 02:41:45 +08:00
|
|
|
|
|
|
|
interface CacheInput {
|
|
|
|
path: string;
|
|
|
|
key: string;
|
|
|
|
restoreKeys?: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setInputs(input: CacheInput) {
|
|
|
|
setInput(Inputs.Path, input.path);
|
|
|
|
setInput(Inputs.Key, input.key);
|
|
|
|
input.restoreKeys &&
|
|
|
|
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearInputs() {
|
|
|
|
delete process.env[getInputName(Inputs.Path)];
|
|
|
|
delete process.env[getInputName(Inputs.Key)];
|
|
|
|
delete process.env[getInputName(Inputs.RestoreKeys)];
|
|
|
|
}
|