fix: use configured furni source and catalog assets
This commit is contained in:
1 parent
aed70db81f
commit
c78f8812ad
25 files changed
+368
-129
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
export function catalogueAssetDirectories(
|
||||
gamedataRoot: string,
|
||||
cwd = process.cwd(),
|
||||
): string[] {
|
||||
const bundled = path.join(cwd, "public", "swf", "c_images", "catalogue");
|
||||
if (!gamedataRoot.trim()) return [bundled];
|
||||
|
||||
return [path.join(gamedataRoot, "c_images", "catalogue"), bundled];
|
||||
}
|
||||
|
||||
export async function readCatalogueAssetFiles(
|
||||
directories: string[],
|
||||
): Promise<string[]> {
|
||||
const files = new Set<string>();
|
||||
for (const directory of directories) {
|
||||
try {
|
||||
for (const file of await fs.readdir(directory)) files.add(file);
|
||||
} catch {
|
||||
// A missing optional source must not hide assets from the other source.
|
||||
}
|
||||
}
|
||||
return [...files];
|
||||
}
|
||||
Reference in new issue
Block a user