Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: Replace symlinks in node_modules by their target in Mac builds #2223

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading