Files: 5f592b5b2689eebe56a9fa59bf969ce504796d42 / build / build-icon.js
725 bytesRaw
1 | const fs = require('fs') |
2 | const path = require('path') |
3 | const sharp = require('sharp') |
4 | const toIco = require('to-ico') |
5 | const icnsConvert = require('@fiahfy/icns-convert') |
6 | |
7 | const image = sharp(path.resolve(__dirname, 'icon.svg')) |
8 | const sizes = [24, 32, 48, 64, 96, 128, 256] |
9 | |
10 | Promise.all(sizes.map(makeIcon)).then((bufs) => { |
11 | createIco(bufs) |
12 | createIcns(bufs) |
13 | }) |
14 | |
15 | function makeIcon (size) { |
16 | return image |
17 | .resize(size, size) |
18 | .png() |
19 | .toBuffer() |
20 | } |
21 | |
22 | function createIco (bufs) { |
23 | toIco(bufs).then(buf => { |
24 | fs.writeFileSync(path.resolve(__dirname, 'icon.ico'), buf) |
25 | }) |
26 | } |
27 | |
28 | function createIcns (bufs) { |
29 | icnsConvert(bufs).then((data) => { |
30 | fs.writeFileSync(path.resolve(__dirname, 'icon.icns'), data) |
31 | }) |
32 | } |
33 |
Built with git-ssb-web