1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
const { existsSync, renameSync } = require("fs");
const { join } = require("path");
module.exports = afterPack = async context => {
const { packager } = context;
const { platformSpecificBuildOptions, config } = packager;
const sources = [platformSpecificBuildOptions.icon, (config.mac && config.mac.icon) || config.icon].filter(
str => !!str
);
// If no explicit sources are defined, fallback to buildResources directory, then default framework icon
let fallbackSources = [packager.getDefaultFrameworkIcon()];
const buildResources = config.directories && config.directories.buildResources;
if (buildResources && existsSync(join(buildResources, "icons"))) {
fallbackSources = [buildResources].concat(fallbackSources);
}
await packager.resolveIcon(sources, fallbackSources, "set");
const filesToRename = [
{
old: "icon_16x16.png",
new: "icon_16.png"
},
{
old: "icon_48x48.png",
new: "icon_48.png"
}
];
filesToRename.forEach(file => {
const oldPath = join(config.directories.output, ".icon-set", file.old);
const newPath = join(config.directories.output, ".icon-set", file.new);
if (existsSync(oldPath)) {
renameSync(oldPath, newPath);
}
});
};
|