remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/apps/remixdesktop/afterbuild.js

31 lines
1.2 KiB

9 months ago
const fs = require('fs');
9 months ago
9 months ago
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) {
9 months ago
return;
}
console.log('AFTER BUILD', context);
9 months ago
9 months ago
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.');
}
9 months ago
9 months ago
// Combine existing and new dmgs, avoiding duplicates
const combinedDmgs = [...new Set([...existingDmgs, ...newDmgs])];
9 months ago
9 months ago
// Write/overwrite the dmgs.json with the combined list of dmgs
fs.writeFileSync('dmgs.json', JSON.stringify({ dmgs: combinedDmgs }, null, 2));
};