@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.
- package/dist/cjs/index.js +53 -70
- 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
|
-
|
|
30
|
-
yield this.createPNGs(0);
|
|
31
|
-
});
|
|
19
|
+
async start() {
|
|
20
|
+
await this.createPNGs(0);
|
|
32
21
|
}
|
|
33
|
-
createPNG(size) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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.
|
|
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.
|
|
52
|
-
"gitHead": "
|
|
51
|
+
"version": "1.5.5",
|
|
52
|
+
"gitHead": "f7a6a79286e4eb85392b5f2d33942ab166142109"
|
|
53
53
|
}
|