2016-12-05 23:28:47 +00:00
|
|
|
const helpers = require('./helpers');
|
2016-11-30 13:51:08 +00:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
|
|
const svgPath = path.join('resources', 'icon.svg');
|
|
|
|
|
const buildDirectory = path.join('build', 'icon');
|
2016-11-29 19:17:15 +00:00
|
|
|
const outputPath = path.join(buildDirectory, 'icon.ico');
|
2016-11-30 13:51:08 +00:00
|
|
|
|
2017-01-06 09:36:58 +00:00
|
|
|
const svgSize = 192;
|
|
|
|
|
const svgDPI = 90;
|
|
|
|
|
|
2016-11-30 13:51:08 +00:00
|
|
|
const sizes = [16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 128, 256];
|
|
|
|
|
|
|
|
|
|
fs.mkdirsSync(buildDirectory);
|
|
|
|
|
|
|
|
|
|
const convertArgs = [];
|
|
|
|
|
sizes.forEach((size) => {
|
|
|
|
|
const pngFile = path.join(buildDirectory, `icon-${size}.png`);
|
|
|
|
|
convertArgs.push(pngFile);
|
|
|
|
|
|
2017-01-06 09:36:58 +00:00
|
|
|
helpers.safeExecFileSync('convert', [
|
|
|
|
|
'-density',
|
|
|
|
|
(size / svgSize) * svgDPI,
|
|
|
|
|
'-background',
|
|
|
|
|
'none',
|
2016-11-30 13:51:08 +00:00
|
|
|
svgPath,
|
2017-01-06 09:36:58 +00:00
|
|
|
pngFile,
|
2016-11-30 13:51:08 +00:00
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
convertArgs.push(outputPath);
|
2016-12-05 23:28:47 +00:00
|
|
|
helpers.safeExecFileSync('convert', convertArgs);
|