This commit is contained in:
TheGiddyLimit
2024-01-01 19:34:49 +00:00
parent 332769043f
commit 8117ebddc5
1748 changed files with 2544409 additions and 1 deletions

28
node/version-bump.js Normal file
View File

@@ -0,0 +1,28 @@
import * as fs from "fs";
import {simpleGit} from "simple-git";
import "../js/parser.js";
import "../js/utils.js";
const git = simpleGit();
const FILES_TO_REPLACE_VERSION_IN = ["js/utils.js"];
const VERSION_MARKER_START = "/* 5ETOOLS_VERSION__OPEN */";
const VERSION_MARKER_END = "/* 5ETOOLS_VERSION__CLOSE */";
const VERSION_REPLACE_REGEXP = new RegExp(`${VERSION_MARKER_START.escapeRegexp()}.*?${VERSION_MARKER_END.escapeRegexp()}`, "g");
async function main () {
const version = JSON.parse(fs.readFileSync("package.json", "utf-8")).version;
const versionReplaceString = `${VERSION_MARKER_START}"${version}"${VERSION_MARKER_END}`;
console.log("Replacing version in files ", FILES_TO_REPLACE_VERSION_IN, " with ", version);
for (const fileName of FILES_TO_REPLACE_VERSION_IN) {
let fileContents = fs.readFileSync(fileName, "utf8");
const contentsWithReplacedVersion = fileContents.replace(VERSION_REPLACE_REGEXP, versionReplaceString);
fs.writeFileSync(fileName, contentsWithReplacedVersion, "utf8");
await git.add(fileName);
}
}
main()
.then(() => console.log("Replacing version in all files."))
.catch(e => { throw e; });