forked from catppuccin/userstyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-checker.ts
More file actions
45 lines (36 loc) 路 1.1 KB
/
Copy pathfile-checker.ts
File metadata and controls
45 lines (36 loc) 路 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { REPO_ROOT } from "@/constants.ts";
import * as fs from "@std/fs";
import * as path from "@std/path";
import core from "@actions/core";
import { log } from "@/logger.ts";
const requiredFiles = [
"catppuccin.user.css",
"preview.webp",
];
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 = path.join(stylesRoot, entry.name);
await Promise.all(requiredFiles.map(async (f) => {
const fp = path.join(styleRoot, f);
const rfp = path.relative(REPO_ROOT, fp);
if (!(await fs.exists(fp))) {
missingFiles.push(rfp);
}
}));
}
// Only write summary if running in GitHub Actions.
if (Deno.env.has("GITHUB_ACTIONS")) {
await core.summary
.addHeading("Missing files")
.addList(missingFiles)
.write();
} else {
for (const file of missingFiles) {
log.error(`File does not exist`, { file });
}
}
return missingFiles.length === 0;
}