@ffflorian/electron-icon-generator 1.15.5 → 1.15.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +13 -18
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
1
1
  #!/usr/bin/env node
2
- var _a;
3
- import importedIcongen from 'icon-gen';
4
2
  import { Jimp } from 'jimp';
5
3
  import fs from 'node:fs/promises';
6
4
  import path from 'node:path';
7
- // compatibility with cjs and esm
8
- const icongen = (_a = importedIcongen.default) !== null && _a !== void 0 ? _a : importedIcongen;
5
+ import { BICUBIC2, createICNS, createICO } from 'png2icons';
9
6
  // eslint-disable-next-line no-magic-numbers
10
7
  const pngSizes = [16, 24, 32, 48, 64, 128, 256, 512, 1024];
11
8
  export class IconGenerator {
@@ -62,26 +59,24 @@ export class IconGenerator {
62
59
  catch (_a) {
63
60
  // no-op
64
61
  }
65
- await icongen(this.PNGoutputDir, macIconsDir, {
66
- icns: {
67
- name: 'icon',
68
- sizes: pngSizes,
69
- },
70
- report: !this.options.silent,
71
- });
72
62
  try {
73
63
  await fs.mkdir(winIconsDir, { recursive: true });
74
64
  }
75
65
  catch (_b) {
76
66
  // no-op
77
67
  }
78
- await icongen(this.PNGoutputDir, winIconsDir, {
79
- icns: {
80
- name: 'icon',
81
- sizes: pngSizes,
82
- },
83
- report: !this.options.silent,
84
- });
68
+ const largestPNGPath = path.join(this.PNGoutputDir, `${pngSizes[pngSizes.length - 1]}.png`);
69
+ const largestPNG = await fs.readFile(largestPNGPath);
70
+ const icnsBuffer = createICNS(largestPNG, BICUBIC2, 0);
71
+ if (icnsBuffer) {
72
+ await fs.writeFile(path.join(macIconsDir, 'icon.icns'), icnsBuffer);
73
+ this.logConsole(`Created "${path.join(macIconsDir, 'icon.icns')}"`);
74
+ }
75
+ const icoBuffer = createICO(largestPNG, BICUBIC2, 0, false, true);
76
+ if (icoBuffer) {
77
+ await fs.writeFile(path.join(winIconsDir, 'icon.ico'), icoBuffer);
78
+ this.logConsole(`Created "${path.join(winIconsDir, 'icon.ico')}"`);
79
+ }
85
80
  this.logConsole('Renaming PNGs to Electron Format');
86
81
  await this.renamePNGs(0);
87
82
  }
package/package.json CHANGED
@@ -3,8 +3,8 @@
3
3
  "bin": "dist/cli.js",
4
4
  "dependencies": {
5
5
  "commander": "15.0.0",
6
- "icon-gen": "5.0.0",
7
- "jimp": "1.6.1"
6
+ "jimp": "1.6.1",
7
+ "png2icons": "2.0.1"
8
8
  },
9
9
  "description": "An icon generator to generate all the icon files needed for electron packaging",
10
10
  "devDependencies": {
@@ -42,5 +42,5 @@
42
42
  "test": "vitest run"
43
43
  },
44
44
  "type": "module",
45
- "version": "1.15.5"
45
+ "version": "1.15.7"
46
46
  }