chore: Run deno fmt

This commit is contained in:
Donovan Glover 2023-08-31 11:51:44 -04:00
parent 824b710eb9
commit f315ce42f6
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 22 additions and 12 deletions

View File

@ -6,33 +6,36 @@ async function getFilesInDirectory(directory: string): Promise<string[]> {
for await (const walkEntry of walk(directory)) { for await (const walkEntry of walk(directory)) {
if (walkEntry.isFile) { if (walkEntry.isFile) {
if (walkEntry.path.includes("default.nix")) continue if (walkEntry.path.includes("default.nix")) continue;
files.push(walkEntry.path) files.push(walkEntry.path);
} }
} }
return files return files;
} }
async function getImportsInFile(file: string): Promise<string[]> { async function getImportsInFile(file: string): Promise<string[]> {
const text = await Deno.readTextFile(file); const text = await Deno.readTextFile(file);
const lines = text.split("\n") const lines = text.split("\n");
const imports = []; const imports = [];
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
if (lines[i].includes("./")) { if (lines[i].includes("./")) {
imports.push(file.split("./")[1].split("/")[0] + "/" + lines[i].split("./")[1].split(" ")[0]) imports.push(
file.split("./")[1].split("/")[0] + "/" +
lines[i].split("./")[1].split(" ")[0],
);
} }
} }
return imports return imports;
} }
export async function assertAllModulesInDirectory(directory: string) { export async function assertAllModulesInDirectory(directory: string) {
const files = await getFilesInDirectory(`./${directory}`) const files = await getFilesInDirectory(`./${directory}`);
const imports = await getImportsInFile(`./${directory}/default.nix`) const imports = await getImportsInFile(`./${directory}/default.nix`);
for (const file of files) { for (const file of files) {
assert(imports.includes(file)) assert(imports.includes(file));
} }
} }

View File

@ -1,9 +1,16 @@
import { assertAllModulesInDirectory } from "./lib.ts"; import { assertAllModulesInDirectory } from "./lib.ts";
const dirs = ["containers", "home", "modules", "overlays", "packages", "specializations"] const dirs = [
"containers",
"home",
"modules",
"overlays",
"packages",
"specializations",
];
for (const dir of dirs) { for (const dir of dirs) {
Deno.test(`imports all modules in ./${dir}`, async () => { Deno.test(`imports all modules in ./${dir}`, async () => {
await assertAllModulesInDirectory(dir) await assertAllModulesInDirectory(dir);
}) });
} }