Move fx_core.js to a new "src" folder, fix small potential bug in the build script

dev
peshomir 2024-03-28 18:44:06 +02:00
parent 7c787e8799
commit a659fa6723
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ const fs = require('fs');
if (!fs.existsSync("./build")) fs.mkdirSync("./build"); if (!fs.existsSync("./build")) fs.mkdirSync("./build");
fs.cpSync("./static/", "./build/", { recursive: true }); fs.cpSync("./static/", "./build/", { recursive: true });
fs.cpSync("./assets/", "./build/assets/", { recursive: true }); fs.cpSync("./assets/", "./build/assets/", { recursive: true });
fs.cpSync("./src/fx_core.js", "./build/fx_core.js");
fs.writeFileSync("./build/index.html", fs.readFileSync("./build/index.html").toString().replace(/buildTimestamp/g, Date.now())); fs.writeFileSync("./build/index.html", fs.readFileSync("./build/index.html").toString().replace(/buildTimestamp/g, Date.now()));
let script = fs.readFileSync('./game/latest.js', { encoding: 'utf8' }).replace("\n", "").trim(); let script = fs.readFileSync('./game/latest.js', { encoding: 'utf8' }).replace("\n", "").trim();
@ -55,10 +56,10 @@ const generateRegularExpression = (/** @type {string} */ code, /** @type {boolea
let groupNumberCounter = 1; let groupNumberCounter = 1;
let raw = escapeRegExp(code).replace(isForDictionary ? /(?:@@)*(@?)(\w+)/g : /()(\w+)/g, (_match, modifier, word) => { let raw = escapeRegExp(code).replace(isForDictionary ? /(?:@@)*(@?)(\w+)/g : /()(\w+)/g, (_match, modifier, word) => {
// if a substitution string for the "word" is specified in the nameMappings, use it // if a substitution string for the "word" is specified in the nameMappings, use it
if (nameMappings && nameMappings[word] !== undefined) return nameMappings[word]; if (nameMappings && nameMappings.hasOwnProperty(word)) return nameMappings[word];
// if the "word" is a number or is one of these specific words, ingore it // if the "word" is a number or is one of these specific words, ingore it
if (/^\d/.test(word) || ["return", "this", "var", "function", "Math"].includes(word)) return word; if (/^\d/.test(word) || ["return", "this", "var", "function", "Math"].includes(word)) return word;
else if (groups[word] !== undefined) return "\\" + groups[word]; // regex numeric reference to the group else if (groups.hasOwnProperty(word)) return "\\" + groups[word]; // regex numeric reference to the group
else { else {
groups[word] = groupNumberCounter++; groups[word] = groupNumberCounter++;
return modifier === "@" ? `(?<${word}>\\w+)` : "(\\w+)"; return modifier === "@" ? `(?<${word}>\\w+)` : "(\\w+)";