From ef5368cdfdfd0cfd379f48b842be64ddbaa7fc46 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Sun, 10 Mar 2024 11:27:41 +0100 Subject: [PATCH] append dmgs --- apps/remixdesktop/afterbuild.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/remixdesktop/afterbuild.js b/apps/remixdesktop/afterbuild.js index 586106fd54..bc2b1ff49d 100644 --- a/apps/remixdesktop/afterbuild.js +++ b/apps/remixdesktop/afterbuild.js @@ -1,6 +1,6 @@ const fs = require('fs'); -exports.default = async function afterbuild(context) { +exports.default = async function afterbuild(context) { // do not run when not on macOS or when not on CIRCLECI if (process.platform !== 'darwin' || !process.env.CIRCLE_BRANCH) { return; @@ -8,10 +8,23 @@ exports.default = async function afterbuild(context) { console.log('AFTER BUILD', context); - const artifactPaths = context.artifactPaths - const dmgs = artifactPaths.filter((dmg) => dmg.endsWith('.dmg')).map((dmg) => `'${dmg}'`) - fs.writeFileSync('dmgs.json', JSON.stringify({ dmgs }, null, 2)) - + const artifactPaths = context.artifactPaths; + const newDmgs = artifactPaths.filter((dmg) => dmg.endsWith('.dmg')).map((dmg) => dmg); // Removed unnecessary quotes for consistency + + let existingDmgs = []; + try { + // Attempt to read the existing dmgs.json file + const data = fs.readFileSync('dmgs.json', 'utf8'); + const parsedData = JSON.parse(data); + existingDmgs = parsedData.dmgs || []; // Ensure existingDmgs is an array + } catch (error) { + // If there's an error reading the file (e.g., file does not exist), proceed with an empty array + console.log('No existing dmgs.json or error reading file, creating new one.'); + } + // Combine existing and new dmgs, avoiding duplicates + const combinedDmgs = [...new Set([...existingDmgs, ...newDmgs])]; -} + // Write/overwrite the dmgs.json with the combined list of dmgs + fs.writeFileSync('dmgs.json', JSON.stringify({ dmgs: combinedDmgs }, null, 2)); +};