Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 7427507

Browse files
committed
fix(forge): adapt removing lproj on macOS
1 parent 3d7784c commit 7427507

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

apps/desktop/electron-forge/forge.config.cjs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,24 +144,36 @@ module.exports = {
144144
hooks: {
145145
// Remove unused locales from the packaged app to save some space.
146146
postPackage(_, packageResult) {
147-
const localesToKeep = LOCALES
147+
const isMac = (process.platform === "darwin");
148+
let localesToKeep = LOCALES
148149
.filter(locale => !locale.contentOnly)
149-
.map(locale => locale.electronLocale.replace("_", "-"));
150+
.map(locale => locale.electronLocale);
151+
if (!isMac) {
152+
localesToKeep.map(locale => locale.replace("_", "-"))
153+
}
154+
150155
const keptLocales = new Set();
151156
const removedLocales = [];
157+
const extension = (isMac ? ".lproj" : ".pak");
152158

153159
for (const outputPath of packageResult.outputPaths) {
154-
const localesDir = path.join(outputPath, 'locales');
160+
const localesDir = isMac
161+
? path.join(outputPath, "TriliumNext Notes.app/Contents/Resources")
162+
: path.join(outputPath, 'locales');
155163

156164
if (!fs.existsSync(localesDir)) {
157-
console.log('No locales directory found. Skipping cleanup.');
158-
return;
165+
console.log(`No locales directory found in '${localesDir}'.`);
166+
process.exit(2);
159167
}
160168

161169
const files = fs.readdirSync(localesDir);
162170

163171
for (const file of files) {
164-
let localeName = path.basename(file, ".pak");
172+
if (!file.endsWith(extension)) {
173+
continue;
174+
}
175+
176+
let localeName = path.basename(file, extension);
165177
if (localeName === "en-US" && process.platform === "win32") {
166178
// If the locale is "en-US" on Windows, we treat it as "en".
167179
// This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".
@@ -174,7 +186,12 @@ module.exports = {
174186
}
175187

176188
const filePath = path.join(localesDir, file);
177-
fs.unlinkSync(filePath);
189+
if (isMac) {
190+
fs.rm(filePath, { recursive: true });
191+
} else {
192+
fs.unlinkSync(filePath);
193+
}
194+
178195
removedLocales.push(file);
179196
}
180197
}

0 commit comments

Comments
 (0)