normalize path on builder
Some checks failed
Build and Release / build-and-release (push) Failing after 30s

This commit is contained in:
2026-05-28 15:18:17 +03:00
parent b49a2e2717
commit 7b87cc9161

View File

@@ -6,11 +6,7 @@ import path from "node:path";
const DEV = process.argv.includes("--dev"); const DEV = process.argv.includes("--dev");
const escape = (str) => const escape = (str) =>
str str.replace(/\s+/g, " ").trim().replace(/"/g, '\\"').replace(/\$/g, "\\$");
.replace(/\s+/g, " ")
.trim()
.replace(/"/g, '\\"')
.replace(/\$/g, "\\$");
function build() { function build() {
const data = fs.readFileSync("./script.php", "utf8"); const data = fs.readFileSync("./script.php", "utf8");
@@ -18,7 +14,7 @@ function build() {
const mountedFiles = new Set(); const mountedFiles = new Set();
const result = data.replace(mountRegex, (_match, file) => { const result = data.replace(mountRegex, (_match, file) => {
let fileContent = fs.readFileSync(file, "utf8"); let fileContent = fs.readFileSync(path.normalize(file), "utf8");
mountedFiles.add(path.resolve(file)); mountedFiles.add(path.resolve(file));
const inlinePhpVarRegex = /"<<BUILDER_PHP_VAR\((?<varName>.*?)\)>>"/g; const inlinePhpVarRegex = /"<<BUILDER_PHP_VAR\((?<varName>.*?)\)>>"/g;
@@ -36,7 +32,7 @@ function build() {
for (const { escapedPlaceholder, varName } of vars) { for (const { escapedPlaceholder, varName } of vars) {
fileContent = fileContent.replace( fileContent = fileContent.replace(
escapedPlaceholder, escapedPlaceholder,
`" . ${varName} . "` `" . ${varName} . "`,
); );
} }
@@ -58,7 +54,9 @@ if (DEV) {
function watchFile(file) { function watchFile(file) {
if (watchers.has(file)) return; if (watchers.has(file)) return;
const watcher = fs.watch(file, () => { const watcher = fs.watch(file, () => {
console.log(`[${new Date().toLocaleTimeString()}] Changed: ${path.relative(".", file)}`); console.log(
`[${new Date().toLocaleTimeString()}] Changed: ${path.relative(".", file)}`,
);
rebuild(); rebuild();
}); });
watchers.set(file, watcher); watchers.set(file, watcher);