From dc05fc6c966f2800a77642f6ef64d7e2f002b125 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Fri, 28 Jul 2023 20:16:07 +0800 Subject: [PATCH] add: build skip update.json change in prerelease --- scripts/build.mjs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 552f25a3..5dd49daa 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -22,6 +22,8 @@ const t = new Date(); const buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", new Date()); const buildDir = "build"; +const isPreRelease = version.includes("-"); + function copyFileSync(source, target) { var targetFile = target; @@ -136,13 +138,16 @@ function replaceString() { `${buildDir}/addon/prefs.js`, `${buildDir}/addon/manifest.json`, `${buildDir}/addon/bootstrap.js`, - "update.json", ], from: replaceFrom, to: replaceTo, countMatches: true, }; + if (!isPreRelease) { + optionsAddon.files.push("update.json"); + } + const replaceResult = replaceInFileSync(optionsAddon); const localeMessage = new Set(); @@ -242,14 +247,20 @@ async function main() { console.log( `[Build] BUILD_DIR=${buildDir}, VERSION=${version}, BUILD_TIME=${buildTime}, ENV=${[ env.NODE_ENV, - ]}`, + ]}, IS_PRE_RELEASE=${[env.IS_PRE_RELEASE]}`, ); clearFolder(buildDir); copyFolderRecursiveSync("addon", buildDir); - copyFileSync("update-template.json", "update.json"); + if (isPreRelease) { + console.log( + "[Build] [Warn] Running in pre-release mode. update.json will not be replaced.", + ); + } else { + copyFileSync("update-template.json", "update.json"); + } await esbuild();