Przeglądaj źródła

fix: missing flags in regex

Sv443 1 rok temu
rodzic
commit
772185d4e0
1 zmienionych plików z 4 dodań i 3 usunięć
  1. 4 3
      src/tools/post-build.ts

+ 4 - 3
src/tools/post-build.ts

@@ -5,6 +5,9 @@ import { exec } from "child_process";
 import dotenv from "dotenv";
 import pkg from "../../package.json" assert { type: "json" };
 
+/** Any type that is either a string or can be implicitly converted to one by having a .toString() method */
+type Stringifiable = string | { toString(): string; };
+
 const { env, exit } = process;
 dotenv.config();
 
@@ -107,12 +110,10 @@ const header = `\
   }
 })();
 
-type Stringifiable = { toString(): string; } | string;
-
 /** Replaces tokens in the format `{{key}}` or `/⋆{{key}}⋆/` of the `replacements` param with their respective value */
 function insertValues(userscript: string, replacements: Record<string, Stringifiable>) {
   for(const key in replacements)
-    userscript = userscript.replace(new RegExp(`(\\/\\*)?{{${key}}}(\\*\\/)?`), String(replacements[key]));
+    userscript = userscript.replace(new RegExp(`(\\/\\*)?{{${key}}}(\\*\\/)?`, "gm"), String(replacements[key]));
   return userscript;
 }