add: build skip update.json change in prerelease

This commit is contained in:
windingwind 2023-07-28 20:16:07 +08:00
parent abc6b658d9
commit dc05fc6c96

View File

@ -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();