Remove duplicate code

This commit is contained in:
2026-10-13 11:57:43 -03:00
parent dfc6a6d77b
commit 5165698fe3
50 changed files with 307 additions and 812 deletions
+7 -6
View File
@@ -6,6 +6,7 @@
import {
entity_model_from_geo,
FORMAT_VERSION,
is_object,
OreJson,
type SpawnJson,
type TagJson,
@@ -288,8 +289,7 @@ async function typecheck_scripts(mod: LoadedMod) {
.map((path) => `${mod.dir}/${path}`);
if (scripts.length === 0) return;
// a mod with its own deno.json is its own deno project, see pack_mod.ts
const config = ["deno.json", "deno.jsonc"].map((name) => `${mod.dir}/${name}`).find(exists) ?? "deno.json";
const config = mod_deno_config(mod.dir) ?? "deno.json";
const output = await new Deno.Command(Deno.execPath(), {
args: ["check", "--config", config, ...scripts],
stdout: "piped",
@@ -341,6 +341,11 @@ function safe_read_dir(dir: string): Deno.DirEntry[] {
}
}
// a mod with its own deno.json is its own deno project, see pack_mod.ts
export function mod_deno_config(mod_dir: string): string | undefined {
return ["deno.json", "deno.jsonc"].map((name) => `${mod_dir}/${name}`).find(exists);
}
function exists(path: string) {
try {
Deno.statSync(path);
@@ -350,10 +355,6 @@ function exists(path: string) {
}
}
function is_object(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
if (import.meta.main) {
const reports = await check_mods();
let errors = 0;