Files
wow-weakauras/WeakAuras/Projects/RaiderSA/buildscript/words2luaArr.js

28 lines
798 B
JavaScript

const fs = require("fs");
const path = require("path");
const WORDS_FILE = path.join(__dirname, "..", "words.txt");
const words = fs.readFileSync(WORDS_FILE).toString().split("\n");
const luaArr = [];
luaArr.push("aura_env.spells = {");
for (let line = 0; line < words.length; line++) {
const lineContent = words[line].trim();
if (/^#\d+/.test(lineContent)) {
const [_, id, mode] = /^#(\d+)!(\d)/.exec(lineContent);
const spellname = words[line + 1].trim();
luaArr.push(`\t[${id}] = {`);
luaArr.push(`\t\t["name"] = "${spellname}",`);
luaArr.push(`\t\t["mode"] = ${mode},`);
luaArr.push("\t},");
} else if (lineContent.includes("##")) {
luaArr.push(`\t-- ${lineContent}`);
}
}
luaArr.push("}");
fs.writeFileSync(path.join(__dirname, "..", "luaarr.lua"), luaArr.join("\n"));