瀏覽代碼

feat: log level tied to build mode

Sv443 1 年之前
父節點
當前提交
8a7918b571
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 5 1
      src/constants.ts
  2. 1 0
      src/tools/post-build.ts

+ 5 - 1
src/constants.ts

@@ -1,7 +1,10 @@
 import type { LogLevel } from "./types";
 
+const modeRaw = "{{MODE}}";
 const branchRaw = "{{BRANCH}}";
 
+/** The mode in which the script was built (production or development) */
+export const mode = modeRaw.match(/^{{.+}}$/) ? "production" : modeRaw;
 /** The branch to use in various URLs that point to the GitHub repo */
 export const branch = branchRaw.match(/^{{.+}}$/) ? "main" : branchRaw;
 
@@ -9,7 +12,8 @@ export const branch = branchRaw.match(/^{{.+}}$/) ? "main" : branchRaw;
  * How much info should be logged to the devtools console?  
  * 0 = Debug (show everything) or 1 = Info (show only important stuff)
  */
-export const logLevel: LogLevel = 0; // TODO: change in prod.
+export const logLevel: LogLevel = mode === "production" ? 1 : 0;
+
 /** Specifies the hard limit for repetitive tasks */
 export const triesLimit = 50;
 /** Specifies the interval in ms for repetitive tasks */

+ 1 - 0
src/tools/post-build.ts

@@ -75,6 +75,7 @@ const header = `\
     let userscript = insertValues(
       String(await readFile(scriptPath)),
       {
+        MODE: mode,
         BRANCH: branch,
         BUILD_NUMBER: lastCommitSha,
       },