| 12345678910111213141516171819202122232425262728293031 |
- import fs from "fs";
- import path from "path";
- export function getJsonData(file: string): unknown {
- const str = fs.readFileSync(file).toString();
- return JSON.parse(str);
- }
- const appDataPath = process.env["AppData"] || `${process.env["HOME"] ?? ""}/Library/Application Support`;
- export const factorioPath = `${appDataPath}/Factorio`;
- export const scriptOutputPath = `${factorioPath}/script-output`;
- export const dataRawPath = `${scriptOutputPath}/data-raw-dump.json`;
- type Locale = Record<string, string>;
- 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) {
- console.log(`❌ ${missing.length} icon(s) are missing:`);
- console.log(missing.map((p) => ` • ${p}`).join("\n"));
- }
- }
|