Skip to content

Commit

Permalink
fix: test with debug output of outDir
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Sep 27, 2024
1 parent 7a51117 commit 1069549
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const main = async () => {
await build({
publish: 'onTag',
config: {
afterAllArtifactBuild: './electron/scripts/afterPack.js',
afterAllArtifactBuild: './electron/scripts/afterAllArtifactBuild.js',
appId: 'xyz.valory.olas-operate-app',
artifactName: artifactName(),
productName: 'Pearl',
Expand Down
54 changes: 54 additions & 0 deletions electron/scripts/afterAllArtifactBuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const fs = require('fs');
const path = require('path');
const os = require('os');

/**
* @param {string} outDir - Output directory of the build
* @param {keyof typeof import('builder-util').Arch} arch - CPU architecture
*/
const renameLatestMacToArchSpecific = (outDir, arch) => {
console.log(`afterPack: renaming latest.yml to latest-mac-${arch}.yml`);

const latestYmlPath = path.join(outDir, 'latest-mac.yml');
const renamedYmlPath = path.join(outDir, `latest-mac-${arch}.yml`);

console.log(`Renaming ${latestYmlPath} to ${renamedYmlPath}`);

if (fs.existsSync(latestYmlPath)) {
fs.renameSync(latestYmlPath, renamedYmlPath);
console.log(`Renamed ${latestYmlPath} to ${renamedYmlPath}`);
} else {
console.error(`Error: ${latestYmlPath} not found in ${outDir}.`);
// Print the contents of outDir for debugging
console.log(`Contents of ${outDir}:`);
fs.readdir(outDir, (err, files) => {
if (err) {
console.error(`Error reading directory ${outDir}:`, err);
} else {
files.forEach((file) => {
console.log(file);
});
}
});
process.exit(1);
}
};

/**
* @note This function is called after the packaging of the app is done.
* @param {import('electron-builder').BuildResult} context - The context object from electron-builder
*/
const afterAllArtifactBuild = async (context) => {
if (os.platform() === 'darwin') {
console.log('afterPack: macOS detected');

if (process.env.ARCH === 'x64') {
renameLatestMacToArchSpecific(context.outDir, 'x64');
}
if (process.env.ARCH === 'arm64') {
renameLatestMacToArchSpecific(context.outDir, 'arm64');
}
}
};

exports.default = afterAllArtifactBuild;
34 changes: 0 additions & 34 deletions electron/scripts/afterPack.js

This file was deleted.

0 comments on commit 1069549

Please sign in to comment.