refactor(scripts): cleanup & enforce code style (#1388)

This commit is contained in:
uncenter authored and GitHub committed 2024-10-27 15:32:00 -04:00
1 parent 7db9b234c1
commit 5d74d700a2
23 files changed
+290 -270

No files matched your search

+14 -13
View File
@@ -1,8 +1,9 @@
import { exists } from "@std/fs";
import { join, relative } from "@std/path";
import { REPO_ROOT } from "@/constants.ts";
import * as fs from "@std/fs";
import * as path from "@std/path";
import core from "@actions/core";
import { REPO_ROOT } from "@/deps.ts";
import { log } from "@/logger.ts";
const requiredFiles = [
@@ -10,19 +11,19 @@ const requiredFiles = [
"preview.webp",
];
export const checkForMissingFiles = async () => {
const stylesRoot = join(REPO_ROOT, "styles");
export async function checkForMissingFiles() {
const stylesRoot = path.join(REPO_ROOT, "styles");
const missingFiles: string[] = [];
for await (const entry of Deno.readDir(stylesRoot)) {
if (!entry.isDirectory) continue;
const styleRoot = join(stylesRoot, entry.name);
const styleRoot = path.join(stylesRoot, entry.name);
await Promise.all(requiredFiles.map(async (f) => {
const fp = join(styleRoot, f);
const rfp = relative(REPO_ROOT, fp);
const fp = path.join(styleRoot, f);
const rfp = path.relative(REPO_ROOT, fp);
if (!(await exists(fp))) {
if (!(await fs.exists(fp))) {
missingFiles.push(rfp);
}
}));
@@ -35,10 +36,10 @@ export const checkForMissingFiles = async () => {
.addList(missingFiles)
.write();
} else {
missingFiles.map((f) => {
log.error(`File does not exist`, { file: f });
});
for (const file of missingFiles) {
log.error(`File does not exist`, { file });
}
}
return missingFiles.length === 0;
};
}