[FEATURE] /* Description: */ Also moves all nodejs stuff into `tools` package. Also adds a basic `CONTRIBUTING.md` file. Superseeds https://github.com/Nomi-CEu/Nomi-CEu/pull/431, which was closed as the branch needed to be renamed, due to the last two items on this list. TODO: - [x] Make it only run on master repo. - [x] Remove qb-lang-revamp branch from the events - [x] Allow workflow to run on all branches starting with test_buildscript? /* Commits: */ * Buildscript Changes * Make Contributing Docs a .md file * updateqb.yml v1 * Test QB change * Add lang file to commit file list * Another Test Change * Test with only lang path, + `./` at beginning of path * Test QB change * updateqb.yml v3 * Test QB Change * Add some debug settings * Remove debug, branch input. Switch to auto-commit action * Make activate: branches prefix `test_buildscript`, commit author GHA bot * Add branch prefix note into CONTRIBUTING.md * Make workflow only run if on master repo
29 lines
893 B
TypeScript
29 lines
893 B
TypeScript
import { overridesFolder, sharedDestDirectory } from "../../../globals";
|
|
|
|
import upath from "upath";
|
|
import fs from "fs";
|
|
|
|
const scannableConfigFile = "config/scannable.cfg";
|
|
|
|
/**
|
|
* Transform the scannable config.
|
|
* Trim excess newlines and remove comments.
|
|
*/
|
|
export default async function transformScannable(): Promise<void> {
|
|
const configPath = upath.join(sharedDestDirectory, overridesFolder, scannableConfigFile);
|
|
|
|
const contents = (await fs.promises.readFile(configPath))
|
|
.toString()
|
|
// Match arrays (S:array < ... >)
|
|
.replace(/([ \t]+)(S:\w+) <([^>]+)>/g, (_, g0, g1, g2) => {
|
|
const body = g2
|
|
.replace(/#[^\r\n]+/gm, "") // Comments
|
|
.replace(/^\s+$/gm, "") // Trailing whitespaces
|
|
.replace(/[\r\n]{2,}/gm, "\n"); // Extra newlines
|
|
|
|
return g0 + g1 + " <" + body + (body ? "" : "\n") + g0 + " >";
|
|
});
|
|
|
|
return fs.promises.writeFile(configPath, contents);
|
|
}
|