mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-07-10 08:55:38 +00:00
16407620e5
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {existsSync, mkdirSync} from "node:fs";
|
|
import type * as CoreApi from "@actions/core";
|
|
import type {Context} from "@actions/github/lib/context";
|
|
import type {Octokit} from "@octokit/rest";
|
|
|
|
import {ALL_AUTODL_MANUFACTURERS, CACHE_DIR} from "./common.js";
|
|
|
|
export async function overwriteCache(_github: Octokit, core: typeof CoreApi, _context: Context, manufacturersCSV?: string): Promise<void> {
|
|
if (!existsSync(CACHE_DIR)) {
|
|
mkdirSync(CACHE_DIR, {recursive: true});
|
|
}
|
|
|
|
const manufacturers = manufacturersCSV ? manufacturersCSV.trim().split(",") : ALL_AUTODL_MANUFACTURERS;
|
|
|
|
for (const manufacturer of manufacturers) {
|
|
// ignore empty strings
|
|
if (!manufacturer) {
|
|
continue;
|
|
}
|
|
|
|
if (!ALL_AUTODL_MANUFACTURERS.includes(manufacturer)) {
|
|
core.error(`Ignoring invalid manufacturer '${manufacturer}'. Expected any of: ${ALL_AUTODL_MANUFACTURERS}.`);
|
|
continue;
|
|
}
|
|
|
|
const {writeCache} = await import(`./${manufacturer}.js`);
|
|
|
|
core.startGroup(manufacturer);
|
|
core.info(`[${manufacturer}] Writing cache...`);
|
|
|
|
try {
|
|
await writeCache();
|
|
} catch (error) {
|
|
core.error((error as Error).message);
|
|
core.debug((error as Error).stack!);
|
|
}
|
|
|
|
core.endGroup();
|
|
}
|
|
}
|