-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: remove unused language locale resources (#1573)
Signed-off-by: Adam Setch <[email protected]>
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const path = require('node:path'); | ||
const fs = require('node:fs'); | ||
|
||
const packageJson = require('../package.json'); | ||
const electronLanguages = packageJson.build.electronLanguages; | ||
|
||
exports.default = async (context) => { | ||
const appName = context.packager.appInfo.productFilename; | ||
const appOutDir = context.appOutDir; | ||
const platform = context.electronPlatformName; | ||
|
||
if (platform !== 'darwin') { | ||
return; | ||
} | ||
|
||
const resourcesPath = path.join( | ||
appOutDir, | ||
`${appName}.app`, | ||
'Contents', | ||
'Frameworks', | ||
'Electron Framework.framework', | ||
'Versions', | ||
'A', | ||
'Resources', | ||
); | ||
|
||
// Get all locale directories | ||
const allLocales = fs | ||
.readdirSync(resourcesPath) | ||
.filter((file) => file.endsWith('.lproj')); | ||
|
||
const langLocales = electronLanguages.map((lang) => `${lang}.lproj`); | ||
|
||
// Remove unused locales | ||
for (const locale of allLocales) { | ||
if (!langLocales.includes(locale)) { | ||
const localePath = path.join(resourcesPath, locale); | ||
fs.rmSync(localePath, { recursive: true }); | ||
} | ||
} | ||
}; |