import { IS_BROWSER } from "$fresh/runtime.ts";

const eulaRegex = /(eula=false)/;
export const checkEULA = (instance = "server") => 
  !IS_BROWSER && !eulaRegex.test(Deno.readTextFileSync(`./${instance}/eula.txt`));
  // true;

export const acceptEULA = (instance = "server") => {
  const eula = Deno.readTextFileSync(`./${instance}/eula.txt`);
  const mod = eula.replace(eulaRegex, "eula=true");
  console.log(mod);
  !IS_BROWSER && Deno.writeTextFileSync(`./${instance}/eula.txt`, mod);
};
