Block registry api
This commit is contained in:
+6
-6
@@ -36,14 +36,14 @@ let repo_mods: ServerModSource[] | undefined;
|
||||
|
||||
// mods straight from their source folders, skipping the build: scripts are imported as typescript. each call gets its
|
||||
// own copy, so a test that changes what it got can't change another test's
|
||||
export function mod_sources(mods_dir: string): ServerModSource[] {
|
||||
if (resolve(mods_dir) !== resolve("mods")) return read_mod_sources(mods_dir);
|
||||
repo_mods ??= read_mod_sources(mods_dir);
|
||||
export async function mod_sources(mods_dir: string): Promise<ServerModSource[]> {
|
||||
if (resolve(mods_dir) !== resolve("mods")) return await read_mod_sources(mods_dir);
|
||||
repo_mods ??= await read_mod_sources(mods_dir);
|
||||
return structuredClone(repo_mods);
|
||||
}
|
||||
|
||||
function read_mod_sources(mods_dir: string): ServerModSource[] {
|
||||
const mods = load_and_check(mods_dir);
|
||||
async function read_mod_sources(mods_dir: string): Promise<ServerModSource[]> {
|
||||
const mods = await load_and_check(mods_dir);
|
||||
const errors = mods.flatMap((mod) => mod.report.errors.map((e) => `${mod.id}: ${e}`));
|
||||
if (errors.length) throw new Error(errors.join("\n"));
|
||||
return load_order(mods).map((mod) => {
|
||||
@@ -94,7 +94,7 @@ export async function test_game(
|
||||
config: Record<string, Record<string, unknown>> = {},
|
||||
) {
|
||||
EverythingRegistry.clear();
|
||||
const mods = mod_sources(mods_dir);
|
||||
const mods = await mod_sources(mods_dir);
|
||||
for (const mod of mods) {
|
||||
if (!config[mod.listing.id]) continue;
|
||||
const changed = apply_config(mod.data.config ?? {}, config[mod.listing.id]);
|
||||
|
||||
Reference in New Issue
Block a user