@ffflorian/electron-icon-generator 1.5.4 → 1.5.5

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/cjs/index.js +53 -70
  2. package/package.json +3 -3
package/dist/cjs/index.js CHANGED
@@ -1,13 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  import * as fs from 'fs-extra';
12
3
  import Jimp from 'jimp';
13
4
  import path from 'path';
@@ -25,74 +16,66 @@ export class IconGenerator {
25
16
  this.iconsDir = path.join(this.options.output, 'icons');
26
17
  this.PNGoutputDir = path.join(this.iconsDir, 'png');
27
18
  }
28
- start() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- yield this.createPNGs(0);
31
- });
19
+ async start() {
20
+ await this.createPNGs(0);
32
21
  }
33
- createPNG(size) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const fileName = `${size.toString()}.png`;
36
- yield fs.ensureDir(this.options.output);
37
- yield fs.ensureDir(this.iconsDir);
38
- yield fs.ensureDir(this.PNGoutputDir);
39
- const image = yield Jimp.read(this.options.input);
40
- const resizeFile = path.join(this.PNGoutputDir, fileName);
41
- yield new Promise((resolve, reject) => image.resize(size, size, (error, result) => (error ? reject(error) : resolve(result))));
42
- yield image.writeAsync(resizeFile);
43
- return `Created "${resizeFile}"`;
44
- });
22
+ async createPNG(size) {
23
+ const fileName = `${size.toString()}.png`;
24
+ await fs.ensureDir(this.options.output);
25
+ await fs.ensureDir(this.iconsDir);
26
+ await fs.ensureDir(this.PNGoutputDir);
27
+ const image = await Jimp.read(this.options.input);
28
+ const resizeFile = path.join(this.PNGoutputDir, fileName);
29
+ await new Promise((resolve, reject) => image.resize(size, size, (error, result) => (error ? reject(error) : resolve(result))));
30
+ await image.writeAsync(resizeFile);
31
+ return `Created "${resizeFile}"`;
45
32
  }
46
- createPNGs(position) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const info = yield this.createPNG(pngSizes[position]);
49
- this.logConsole(info);
50
- if (position < pngSizes.length - 1) {
51
- yield this.createPNGs(position + 1);
52
- }
53
- else {
54
- const macIconsDir = path.join(this.iconsDir, 'mac');
55
- const winIconsDir = path.join(this.iconsDir, 'win');
56
- yield fs.ensureDir(macIconsDir);
57
- yield icongen(this.PNGoutputDir, macIconsDir, {
58
- icns: {
59
- name: 'icon',
60
- sizes: pngSizes,
61
- },
62
- report: !this.options.silent,
63
- });
64
- yield fs.ensureDir(winIconsDir);
65
- yield icongen(this.PNGoutputDir, winIconsDir, {
66
- icns: {
67
- name: 'icon',
68
- sizes: pngSizes,
69
- },
70
- report: !this.options.silent,
71
- });
72
- this.logConsole('Renaming PNGs to Electron Format');
73
- yield this.renamePNGs(0);
74
- }
75
- });
33
+ async createPNGs(position) {
34
+ const info = await this.createPNG(pngSizes[position]);
35
+ this.logConsole(info);
36
+ if (position < pngSizes.length - 1) {
37
+ await this.createPNGs(position + 1);
38
+ }
39
+ else {
40
+ const macIconsDir = path.join(this.iconsDir, 'mac');
41
+ const winIconsDir = path.join(this.iconsDir, 'win');
42
+ await fs.ensureDir(macIconsDir);
43
+ await icongen(this.PNGoutputDir, macIconsDir, {
44
+ icns: {
45
+ name: 'icon',
46
+ sizes: pngSizes,
47
+ },
48
+ report: !this.options.silent,
49
+ });
50
+ await fs.ensureDir(winIconsDir);
51
+ await icongen(this.PNGoutputDir, winIconsDir, {
52
+ icns: {
53
+ name: 'icon',
54
+ sizes: pngSizes,
55
+ },
56
+ report: !this.options.silent,
57
+ });
58
+ this.logConsole('Renaming PNGs to Electron Format');
59
+ await this.renamePNGs(0);
60
+ }
76
61
  }
77
62
  logConsole(...messages) {
78
63
  if (!this.options.silent) {
79
64
  console.info(...messages);
80
65
  }
81
66
  }
82
- renamePNGs(position) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const startName = `${pngSizes[position]}.png`;
85
- const endName = `${pngSizes[position]}x${pngSizes[position]}.png`;
86
- const startFile = path.join(this.PNGoutputDir, startName);
87
- const endFile = path.join(this.PNGoutputDir, endName);
88
- yield fs.rename(startFile, endFile);
89
- this.logConsole(`Renamed "${startName}" to "${endName}".`);
90
- if (position < pngSizes.length - 1) {
91
- yield this.renamePNGs(position + 1);
92
- }
93
- else {
94
- this.logConsole('\nAll done');
95
- }
96
- });
67
+ async renamePNGs(position) {
68
+ const startName = `${pngSizes[position]}.png`;
69
+ const endName = `${pngSizes[position]}x${pngSizes[position]}.png`;
70
+ const startFile = path.join(this.PNGoutputDir, startName);
71
+ const endFile = path.join(this.PNGoutputDir, endName);
72
+ await fs.rename(startFile, endFile);
73
+ this.logConsole(`Renamed "${startName}" to "${endName}".`);
74
+ if (position < pngSizes.length - 1) {
75
+ await this.renamePNGs(position + 1);
76
+ }
77
+ else {
78
+ this.logConsole('\nAll done');
79
+ }
97
80
  }
98
81
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "devDependencies": {
12
12
  "@types/fs-extra": "11.0.4",
13
13
  "rimraf": "5.0.7",
14
- "typescript": "5.4.5"
14
+ "typescript": "5.5.2"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">= 18.0"
@@ -48,6 +48,6 @@
48
48
  "test": "exit 0"
49
49
  },
50
50
  "type": "module",
51
- "version": "1.5.4",
52
- "gitHead": "28c184f53a87d8eb082cc27c923ef7b352bbe875"
51
+ "version": "1.5.5",
52
+ "gitHead": "f7a6a79286e4eb85392b5f2d33942ab166142109"
53
53
  }