Add and fix tests

This commit is contained in:
Cooldude2606 committed 2024-11-13 22:17:27 +00:00
1 parent 81444cc447
commit 3850558d49
8 files changed
+60 -15

No files matched your search

+1 -3
View File
@@ -620,11 +620,9 @@ export default class Host extends lib.Link {
async fetchMods(mods: Iterable<lib.ModRecord>) {
// This is better than the previous hard coded names
// But it really shouldn't be a hard coded version either
const builtinModNames = lib.ModPack.getBuiltinMods("2.0").map(builtinMod => builtinMod.name);
const builtinModNames = lib.ModPack.getBuiltinModNames("2.0");
const modInfos: Promise<lib.ModInfo>[] = [];
for (const mod of mods) {
// XXX These mods ship with Factorio, but the list of mods may
// change and should not be hardcoded here.
if (builtinModNames.includes(mod.name)) {
continue;
}
+10 -7
View File
@@ -103,8 +103,8 @@ async function loadFile(server: FactorioServer, modVersions: Map<string, string>
let [, mod, filePath] = match;
const builtinMods = lib.ModPack.getBuiltinMods(server.version!);
if (builtinMods.some(builtinMod => builtinMod.name === mod)) {
const builtinModNames = ["core", ...lib.ModPack.getBuiltinModNames(server.version!)];
if (builtinModNames.includes(mod)) {
try {
return await fs.readFile(server.dataPath(mod, filePath));
} catch (err: any) {
@@ -397,15 +397,18 @@ async function exportLocale(
}
}
const builtinMods = lib.ModPack.getBuiltinMods(server.version!);
for (const builtinMod of builtinMods) {
const localeFilePath = server.dataPath(builtinMod.name, "locale", languageCode, `${builtinMod.name}.cfg`);
const builtinModNames = [
// Filter if on builtin mods so "core" does not need to be specified in modOrder
"core", ...lib.ModPack.getBuiltinModNames(server.version!).filter(mod => modOrder.includes(mod)),
];
for (const builtinModName of builtinModNames) {
const localeFilePath = server.dataPath(builtinModName, "locale", languageCode, `${builtinModName}.cfg`);
mergeLocale(lib.parse(await fs.readFile(localeFilePath, "utf8")));
}
const builtinModNames = ["export", ...builtinMods.map(builtinMod => builtinMod.name)];
const builtinModNamesExport = ["export", ...builtinModNames];
for (let mod of modOrder) {
if (builtinModNames.includes(mod)) {
if (builtinModNamesExport.includes(mod)) {
continue;
}
+2 -2
View File
@@ -346,9 +346,9 @@ function reorderDependencies(modules: SaveModule[]) {
const knownScenarios: Record<string, lib.ModuleInfo> = {
// First seen in 0.17.63
"4e866186ebe297f1038fd325b09df1a1f5e2fdd1": new lib.ModuleInfo("freeplay", "0.17.63", [], ["scenario"]),
// First seen in 1.2.0 (aka 2.0) TODO Uncomment once clusterio lib supports 2.0
// First seen in 2.0 TODO Uncomment once clusterio lib supports 2.0
// The rest of the code has already been updated to support the new control.lua file for 2.0
// "bcbdde18ce4ec16ebfd93bd694cd9b12ef969c9a": new lib.ModuleInfo("freeplay", "1.2.0", [], ["scenario"]),
// "bcbdde18ce4ec16ebfd93bd694cd9b12ef969c9a": new lib.ModuleInfo("freeplay", "2.0.0", [], ["scenario"]),
};
/**