Prune frameworks folder before zipping release
This commit is contained in:
parent
4763831d3e
commit
31d2cce309
4 changed files with 51 additions and 88 deletions
48
ts/scripts/prune-macos-release.ts
Normal file
48
ts/scripts/prune-macos-release.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2020-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
import type { AfterPackContext } from 'electron-builder';
|
||||
|
||||
export async function afterPack({
|
||||
appOutDir,
|
||||
packager,
|
||||
electronPlatformName,
|
||||
}: AfterPackContext): Promise<void> {
|
||||
if (electronPlatformName !== 'darwin') {
|
||||
return;
|
||||
}
|
||||
|
||||
const { productFilename } = packager.appInfo;
|
||||
|
||||
const frameworkDir = path.join(
|
||||
appOutDir,
|
||||
`${productFilename}.app`,
|
||||
'Contents',
|
||||
'Frameworks',
|
||||
'Electron Framework.framework'
|
||||
);
|
||||
|
||||
const versionsDir = path.join(frameworkDir, 'Versions');
|
||||
const currentVersion = path.join(versionsDir, 'Current');
|
||||
|
||||
const subFolders = await fs.readdir(currentVersion);
|
||||
for (const folder of subFolders) {
|
||||
const sourcePath = path.join(currentVersion, folder);
|
||||
const targetPath = path.join(frameworkDir, folder);
|
||||
|
||||
console.log(
|
||||
'Replacing electron framework symlink with real folder',
|
||||
sourcePath
|
||||
);
|
||||
rimraf.sync(targetPath);
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await fs.rename(sourcePath, targetPath);
|
||||
}
|
||||
|
||||
console.log('Removing duplicate electron framework', versionsDir);
|
||||
rimraf.sync(versionsDir);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue