mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 11:25:31 +00:00
Improve string split
This commit is contained in:
parent
e561127c3e
commit
d60d2bef10
8 changed files with 95 additions and 27 deletions
|
@ -19,15 +19,10 @@ async function run(): Promise<void> {
|
|||
const primaryKey = core.getInput(Inputs.Key, { required: true });
|
||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||
|
||||
const restoreKeys = core
|
||||
.getInput(Inputs.RestoreKeys)
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
|
||||
const cachePaths = core
|
||||
.getInput(Inputs.Path, { required: true })
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
|
||||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
|
||||
try {
|
||||
const cacheKey = await cache.restoreCache(
|
||||
|
|
|
@ -31,10 +31,9 @@ async function run(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
const cachePaths = core
|
||||
.getInput(Inputs.Path, { required: true })
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
|
||||
try {
|
||||
await cache.saveCache(cachePaths, primaryKey);
|
||||
|
|
|
@ -45,3 +45,14 @@ export function logWarning(message: string): void {
|
|||
export function isValidEvent(): boolean {
|
||||
return RefKey in process.env && Boolean(process.env[RefKey]);
|
||||
}
|
||||
|
||||
export function getInputAsArray(
|
||||
name: string,
|
||||
options?: core.InputOptions
|
||||
): string[] {
|
||||
return core
|
||||
.getInput(name, options)
|
||||
.split("\n")
|
||||
.map(s => s.trim())
|
||||
.filter(x => x !== "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue