import fs from "fs"; import path from "path"; export function getJsonData(file: string): unknown { const str = fs.readFileSync(file).toString(); return JSON.parse(str); } export let factorioPath: string = ""; var isWin = process.platform === "win32"; if (isWin) { const appDataPath = process.env["AppData"] || `${process.env["HOME"] ?? ""}/Library/Application Support`; factorioPath = `${appDataPath}/Factorio`; } else { factorioPath = `/home/clovis/shared/Factorio`; } export const scriptOutputPath = `${factorioPath}/script-output`; export const dataRawPath = `${scriptOutputPath}/data-raw-dump.json`; type Locale = Record; export function getLocale(file: string): Locale { const path = `${scriptOutputPath}/${file}`; return getJsonData(path) as Locale; } export function checkIcons(icons: string[]) { const missing: string[] = []; for (const icon of icons) { const fullPath = path.resolve(scriptOutputPath, icon); if (!fs.existsSync(fullPath)) missing.push(fullPath); } if (missing.length > 0) { console.log(`❌ ${missing.length} icon(s) are missing:`); console.log(missing.map((p) => ` • ${p}`).join("\n")); } }