file.helper.ts 501 B

1234567891011121314151617
  1. import fs from "fs";
  2. export function getJsonData(file: string): unknown {
  3. const str = fs.readFileSync(file).toString();
  4. return JSON.parse(str);
  5. }
  6. const appDataPath =
  7. process.env["AppData"] || `${process.env["HOME"] ?? ""}/Library/Application Support`;
  8. export const factorioPath = `${appDataPath}/Factorio`;
  9. type Locale = Record<string, string>;
  10. export function getLocale(file: string): Locale {
  11. const path = `${factorioPath}/script-output/${file}`;
  12. return getJsonData(path) as Locale;
  13. }