Skip to content

Commit

Permalink
add: build skip update.json change in prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Jul 28, 2023
1 parent abc6b65 commit dc05fc6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

Expand Down

0 comments on commit dc05fc6

Please sign in to comment.