const sharp = require("sharp"); const fs = require("fs"); const path = require("path"); const iconPath = path.resolve(__dirname, "res", "icon", "ios"); if (!fs.existsSync(iconPath)) { if (fs.mkdirSync(iconPath, { recursive: true })) { return; } } var sizeList = [ 20, 29, 40, 50, 57, 58, 60, 72, 76, 80, 87, 100, 114, 120, 144, 152, 167, 180, 1024, ]; var config = ""; sizeList.forEach((size) => { config += `\n`; sharp("icon.png") .resize(size) .toBuffer() .then((data) => { var file = fs.open( path.resolve(iconPath, `icon-${size}.png`), "w", (err, fd) => { if (err) { return console.error(err); } fs.writeFile(fd, data, (err) => { if (err) { return console.error(err); } }); } ); }) .catch((e) => { console.log(e); }); }); fs.writeFile(path.resolve(iconPath, "config"), config, (err) => {});