Skip to content

Commit

Permalink
Merge pull request #2223 from headlamp-k8s/fix-mac-notarization-verif…
Browse files Browse the repository at this point in the history
…ication

app: Replace symlinks in node_modules by their target in Mac builds
  • Loading branch information
joaquimrocha authored Jul 31, 2024
2 parents 89ab876 + 2d0a239 commit b75df0a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/scripts/after-pack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const child_process = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');

Expand All @@ -18,6 +19,26 @@ exports.default = async context => {
console.error('Failed to copy node_modules after pack:', err);
}

// Mac has a problem with symlinks in the node_modules directory, so we replace them.
if (context.electronPlatformName === 'darwin') {
const tmpNodeModules = dest + '.tmp';

// Copy the node_modules directory to a temporary location, replacing any symlinks with the files they point to
child_process.spawnSync('rsync', [
'--archive',
'--verbose',
'--copy-links',
dest + '/',
tmpNodeModules,
]);

// Remove the original node_modules directory
fs.rmSync(dest, { recursive: true, force: true });

// Move the copied directory back to the original location
fs.renameSync(tmpNodeModules, dest);
}

if (fs.existsSync('.env')) {
console.info('Copying .env file to app resources directory!');
try {
Expand Down

0 comments on commit b75df0a

Please sign in to comment.